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

Type is lost when coming from another module method #85

Open
npirotte opened this issue Jan 5, 2017 · 1 comment
Open

Type is lost when coming from another module method #85

npirotte opened this issue Jan 5, 2017 · 1 comment

Comments

@npirotte
Copy link

npirotte commented Jan 5, 2017

I had some issue when the type of an export statement is coming from another module.

Example:

// firstFile.ts
export const TestStatic: string = "Hello !";
export const TestMethod: () => string = () => "Hello !";
// anotherFile.ts
import * as firstFile form "./firstFile"

export const test1 = ConsoleTryCatchGard.TestStatic;
export const test2 = ConsoleTryCatchGard.TestMethod();

Compiles to:

declare module 'anotherFile' {
  export const test1: any;
  export const test2: any;
}

Expected:

declare module 'anotherFile' {
  export const test1: string;
  export const test2: string;
}

generated with dts-generator --name console --project ./ --out package-name.d.ts and dts 2.0.0

PS: In IDE (VS code), type is not lost
PS2: When firstFile module comes from an external module (js file + defefinition.d.ts), everything works as expected.

@npirotte npirotte changed the title Type is lost when coming from another method Type is lost when coming from another module method Jan 5, 2017
@npirotte
Copy link
Author

npirotte commented Mar 1, 2017

For information, another similar bug was found with interfaces :

Example:

// firstFile.ts
export interface IProps { ... }
// anotherFile.ts
import IProps form "./firstFile"

export const test1 = StatelessComponent<IProps>;

Compiles to:

declare module 'anotherFile' {
  export const test1: StatelessComponent<any>;
}

Expected:

declare module 'anotherFile' {
  import IProps form "./firstFile"
  export const test1: StatelessComponent<IProps>;
}

@dylans dylans added this to the 2.2.0 milestone Mar 6, 2017
@dylans dylans modified the milestones: 2.2.0, 3.1 Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants