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

Buggy(?) namespace collision with internal modules. #1225

Closed
sccolbert opened this issue Nov 20, 2014 · 2 comments
Closed

Buggy(?) namespace collision with internal modules. #1225

sccolbert opened this issue Nov 20, 2014 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@sccolbert
Copy link

I have the following:

// third-party.d.ts
declare module foo.bar {
  export interface IBar<T> {
    a: T;
  }
}
// bar.ts
module bar {
  export interface IBar {
    a: number;
  }
}
// main.ts
module foo.main {
  import IBar = foo.bar.IBar;
  import IBar2 = bar.IBar;
  export var a: IBar<number>;
  export var b: IBar2;
}

compiling with:

tsc -d bar.ts main.ts third-party.d.ts

fails with:

main.ts(5,17): error TS2314: Generic type 'IBar<T>' requires 1 type argument(s).

The issue appears to be because the foo.main shares the foo namespace with the third party foo.bar and cannot distinguish the thirty party namespace from the top-level bar namespace.

Updating the main file to drop the imports:

module foo.main {
  export var a: foo.bar.IBar<number>;
  export var b: bar.IBar2;
}

yields this error:

main.ts(5,17): error TS2305: Module 'foo.bar' has no exported member 'IBar2'

Is there any way to resolve the name clash? This simple example aside, you can imaging a large project which contains a module like somecompany.utility, which would prevent the use of any top-level utility module in the future.

@danquirk
Copy link
Member

A way to resolve the name clash is covered by #983 which includes suggested workarounds in the interim. Hopefully one of those techniques can help unblock you. Let me know if that's not right or else we can close this as a duplicate.

@sccolbert
Copy link
Author

That issue covers it. Thanks!

@danquirk danquirk added the Duplicate An existing issue was already created label Nov 20, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants