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

Declaration merging conflicts when using export statement #9639

Closed
aleung opened this issue Jul 12, 2016 · 1 comment
Closed

Declaration merging conflicts when using export statement #9639

aleung opened this issue Jul 12, 2016 · 1 comment
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created

Comments

@aleung
Copy link

aleung commented Jul 12, 2016

TypeScript Version: 1.8.10 & 2.0.0@beta

I follow the example in Module Augmentation and write below code. The only different is that I use export statement in someclass.ts.

// someclass.ts
class SomeClass {
}
export {SomeClass}

// augmented.ts
import { SomeClass } from "./someclass";
declare module "./someclass" {
  interface SomeClass {
    hello(): void;
  }
}
SomeClass.prototype.hello = function() {
  return this;
}

// consumer.ts
import { SomeClass } from "./someclass";
import "./augmented";
new SomeClass().hello();

It gives compile error:

augmented.ts(7,1): error TS2304: Cannot find name 'SomeClass'.
consumer.ts(3,5): error TS2304: Cannot find name 'SomeClass'.
someclass.ts(6,1): error TS2484: Export declaration conflicts with exported declaration of 'SomeClass'

I change back someclass.ts to use declaration export, then compile success.

// someclass.ts
export class SomeClass {
}

Suppose two export forms should behave the same. Is it a bug?

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 13, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 22, 2016

Duplicate of #9127

@mhegazy mhegazy closed this as completed Sep 22, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Sep 22, 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 Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants