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

Auto-import fails for default exports that are the result of declaration merging #24535

Closed
dfreeman opened this issue May 31, 2018 · 3 comments · Fixed by #24539
Closed

Auto-import fails for default exports that are the result of declaration merging #24535

dfreeman opened this issue May 31, 2018 · 3 comments · Fixed by #24539
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@dfreeman
Copy link
Contributor

TypeScript Version: 3.0.0-dev.20180531

Search Terms: various combinations of merge, default, import, suggestion, auto

Code

This issue occurs when a default export is augmented in another declaration, which I originally ran into when testing out DefinitelyTyped/DefinitelyTyped#26154

// file: a.ts
declare module 'my-class' {
    export default class MyClass { /* ... */ }
}

// file: b.ts
declare module 'my-class' {
    export default interface MyClass { /* ... */ }
}

Expected behavior:

Typing MyClass and requesting suggested fixes includes the option to auto-import MyClass from 'my-class'.

Actual behavior:

An entry in MyClass appears in the list, but selecting it does nothing. Debugging indicates that this assertion is failing because the exportInfos array is empty.

I have a branch with a new (initially failing) unit test and a fix, but wanted to get a bug filed first.

Playground Link: N/A (as far as I can tell, suggested fixes aren't available in the playground)

Related Issues: I found #14080 in the course of searching around, but parallel export defaults appear to work fine for augmentation at least for the use cases I've run into.

@mhegazy
Copy link
Contributor

mhegazy commented May 31, 2018

This is just not a supported pattern at the moment. you can not augment a default export. #14080 tracks fixing that. i suggests adding this repro to #14080

@mhegazy mhegazy added the Duplicate An existing issue was already created label May 31, 2018
@dfreeman
Copy link
Contributor Author

dfreeman commented May 31, 2018

I'm a bit confused — the augmentation itself appears to work exactly as expected, e.g. in this playground. The only problem I was running into was with the auto-import.

Is it possible default export augmentation was incidentally supported as part of some other change and just doesn't have any test coverage?

@mhegazy mhegazy added Bug A bug in TypeScript and removed Duplicate An existing issue was already created labels May 31, 2018
@mhegazy
Copy link
Contributor

mhegazy commented May 31, 2018

looks like we fixed #14080 at some point..

@mhegazy mhegazy assigned ghost May 31, 2018
@mhegazy mhegazy added this to the TypeScript 3.0 milestone May 31, 2018
@ghost ghost closed this as completed in #24539 Jun 1, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 2, 2018
@microsoft microsoft locked and limited conversation to collaborators Aug 2, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants