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

[3.5.1] Incorrect generated declaration file #31676

Closed
amanmahajan7 opened this issue May 30, 2019 · 6 comments · Fixed by #31971

Comments

@amanmahajan7
Copy link

commented May 30, 2019

TypeScript Version: 3.5.1, 3.6.0-dev.20190530

Search Terms:
declaration, generated types, incorrect default export

Code

function A() {  }

function B() { }

export function C() {
  return null;
}

C.A = A;
C.B = B;

run tsc --declaration

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

Expected behavior:

declare function A(): void;
declare function B(): void;
export declare function C(): null;
export declare namespace C {
    var A: typeof A;
    var B: typeof B;
}

Actual behavior:

declare function A(): void;
declare function B(): void;
declare function C(): null;
declare namespace C {
    var A: typeof A;
    var B: typeof B;
}
export default C;

Typescript 3.5.1 is adding a default export which is incorrect.

Playground Link:

Related Issues:

@amanmahajan7 amanmahajan7 changed the title Incorrect generated declaration file [3.5.1] Incorrect generated declaration file May 30, 2019
@MayhemYDG

This comment has been minimized.

Copy link

commented May 30, 2019

It's fine in TS ~3.4 btw.

@nicojs

This comment has been minimized.

Copy link

commented May 30, 2019

This breaks a lot of monorepos using project references since they all rely on declaration files. This makes 3.5 unusable for us. Otherwise no problems with the migration though.

@AnyhowStep

This comment has been minimized.

Copy link
Contributor

commented Jun 15, 2019

A workaround for now,

#31918 (comment)

weswigham added a commit to weswigham/TypeScript that referenced this issue Jun 18, 2019
weswigham added a commit that referenced this issue Jun 20, 2019
…espace members (#31971)

* Fake up a namespace enclosing declaration when generating expando namespace members

* Fix #31676
@nicojs

This comment has been minimized.

Copy link

commented Jun 21, 2019

Cool! Thanks for fixing @weswigham

I see the 3.6 milestone is linked here. Would it be possible to get this in a patch release instead? I'm pretty desprerate 😅

@weswigham

This comment has been minimized.

Copy link
Member

commented Jun 21, 2019

cc @DanielRosenwasser

weswigham added a commit to weswigham/TypeScript that referenced this issue Jun 21, 2019
…espace members (microsoft#31971)

* Fake up a namespace enclosing declaration when generating expando namespace members

* Fix microsoft#31676
@nicojs

This comment has been minimized.

Copy link

commented Jul 9, 2019

Thanks! This issue is now fixed in TS 3.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.