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 emit for aliased exports used in export assignments is broken #19825

Closed
weswigham opened this issue Nov 8, 2017 · 1 comment · Fixed by #19852
Closed

Declaration emit for aliased exports used in export assignments is broken #19825

weswigham opened this issue Nov 8, 2017 · 1 comment · Fixed by #19852
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue

Comments

@weswigham
Copy link
Member

weswigham commented Nov 8, 2017

TypeScript Version: 2.7.0-dev.201xxxxx

Code

// @declaration: true
// @filename: /a.ts
class C {}
export { C as D }

// @filename: /b.ts
import * as a from "./a";
export default a.D;

Expected behavior:

// /a.d.ts
declare class C {}
export { C as D }
// /b.d.ts 
import * as a from "./a";
declare const _default: typeof a.D;
export default _default;

Actual behavior:

/b.ts(2,1): error TS4082: Default export of the module has or is using private name 'default'.


==== /a.ts (0 errors) ====
    class C {}
    export { C as D }
    
==== /b.ts (1 errors) ====
    import * as a from "./a";
    export default a.D;
    ~~~~~~~~~~~~~~~~~~~
!!! error TS4082: Default export of the module has or is using private name 'default'.

I think #19428 may have been an indicator of a larger issue, and the fix applied for it may have been too narrow (or it may be unrelated, haven't run a bisect yet). I've been having issues merging the fix into the symbol display builder PR (since it either fixes the observed bug and breaks all the type/symbol baselines or doesn't fix the bug, depending on how I merge it), so to track down how to implement the fix in the node builder instead of the symbol display builder I started looking for similar cases to see how we behave and found this.

@weswigham weswigham self-assigned this Nov 8, 2017
@weswigham
Copy link
Member Author

Root issue: a.D's type has a .symbol corresponding to the local symbol of C - which is reasonable. However the issue is in getAccessibleSymbolChain, which then returns the default export assignment of module b's symbol as the chain... which, perhaps obviously, has no visible declarations, as a default.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants