Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove restriction on external module augmentations introducing new top-level names #8478

Closed
RyanCavanaugh opened this issue May 5, 2016 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped

Comments

@RyanCavanaugh
Copy link
Member

Module augmentation cannot introduce new names in the top level scope

This error is stopping us from accurately representing UMD-augmenting modules like moment-range. While it's a correct restriction for ES6 values, it's not correct for legacy modules, nor is it a correct restriction for types (e.g. you might want to write an interface in a module augment to provide a type of a new overload parameter)

@RyanCavanaugh RyanCavanaugh self-assigned this May 5, 2016
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped labels May 5, 2016
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.0 milestone May 5, 2016
@mhegazy
Copy link
Contributor

mhegazy commented May 5, 2016

@vladima any concerns here?

@kitsonk
Copy link
Contributor

kitsonk commented May 19, 2016

Just ran across this while trying to convert to UMD definitions, glad it is fixed. Just wanted to mention too, there is nothing preventing an ES6 module from grabbing a reference to global and augmenting it. For example, this is completely valid:

'use strict';
const global = Function('return this')();
global.foo = 'bar';
console.log(foo); // logs "bar"

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 19, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped
Projects
None yet
Development

No branches or pull requests

3 participants