Typescript: [3.5.1] Incorrect generated declaration file

Created on 30 May 2019  路  6Comments  路  Source: microsoft/TypeScript


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:

Bug

Most helpful comment

Thanks! This issue is now fixed in TS 3.5.3

All 6 comments

It's fine in TS ~3.4 btw.

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.

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 馃槄

cc @DanielRosenwasser

Thanks! This issue is now fixed in TS 3.5.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tenry92 picture tenry92  路  146Comments

RyanCavanaugh picture RyanCavanaugh  路  205Comments

blakeembrey picture blakeembrey  路  171Comments

chanon picture chanon  路  138Comments

rwyborn picture rwyborn  路  210Comments