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

Disallow global namespace pollution: External ambient module declaration should not override other external module typings #5808

Closed
falsandtru opened this issue Nov 26, 2015 · 2 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@falsandtru
Copy link
Contributor

Ambient module declaration scope should be only own module(node package).

// node_modules/foo/types.d.ts
declare module 'foo' {
  export var fizz;
}
declare module 'bar' {
  export var fizz;
}

// node_modules/foo/index.d.ts
import './types.d';
export * from 'foo'; // should need re-exporting of ambient module for exporting as an external module.
                     // or should export only module named by own module(node package) name, but it is weak to typo.

// node_modules/bar/index.d.ts
export var bazz;

// index.ts
import {fizz} from 'foo';
import {bazz} from 'bar'; // should not be type error, this is incorrect error.

bar self hosted typings overridden by ambient module declarations in foo. This is global namespace pollution. Global namespace management should be systematic.

@falsandtru falsandtru changed the title External ambient module declaration should not override other external module declaration External ambient module declaration should not override other external module typings Nov 26, 2015
@falsandtru falsandtru changed the title External ambient module declaration should not override other external module typings Disallow global namespace pollution: External ambient module declaration should not override other external module typings Nov 26, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Dec 1, 2015

While i do agree that global namespace pollution is bad, it does exist and ppl build large scale applications and libraries on top of that. i think there is enough user feedback to allow/regulate more of this side effects rather than to limit it. see #5269 and #5867 to name a few..

@mhegazy mhegazy closed this as completed Dec 1, 2015
@mhegazy mhegazy added Suggestion An idea for TypeScript Declined The issue was declined as something which matches the TypeScript vision labels Dec 1, 2015
@falsandtru
Copy link
Contributor Author

All right, thanks.

@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
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants