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 won't import default exports more than once. #44688

Closed
KodyJKing opened this issue Jun 22, 2021 · 3 comments
Closed

Auto-import won't import default exports more than once. #44688

KodyJKing opened this issue Jun 22, 2021 · 3 comments
Assignees
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@KodyJKing
Copy link

KodyJKing commented Jun 22, 2021

Bug Report

After auto-importing a default export once, I have to restart the language server to auto-import a default export again.

🔎 Search Terms

Typescript VSCode auto-import default exports not working

🕗 Version & Regression Information

I can reproduce this with 4.3.0-beta through 4.4.0-dev.20210621. It works normally for me with 4.2.4 and lower.

I tested this in two environments, Windows 7 with NodeJs v14.15.4 and Windows 10 with NodeJs v14.17.1. I was using VSCode v1.57.1 for both.

💻 Code

// import Bar from "./Bar"
// import Foo from "./Foo"

class Baz {
    foo: Foo // Auto-importing this will work.
    bar: Bar // Then auto-importing this will fail.
}

Here is a repository that demonstrates the issue.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 22, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.4.0 (Beta) milestone Jun 22, 2021
@andrewbranch
Copy link
Member

@KodyJKing I can’t reproduce this with any TS version. I’m on a Mac and don’t have a Windows VM handy at the moment. I can get one set up or get a colleague to try this, but I want to double check a couple things first if you’re willing:

  1. Can you try the latest nightly?
  2. While gathering logs from TS Server?

Thanks!

@andrewbranch andrewbranch added Needs More Info The issue still hasn't been fully clarified and removed Needs Investigation This issue needs a team member to investigate its status. labels Jul 8, 2021
@KodyJKing
Copy link
Author

@andrewbranch I can't reproduce this anymore on the latest. I'm not sure if this is relevant anymore, but here's the error log from when I reproduce it using 4.4.0-dev.20210621:

Err 299   [22:51:07.516] Exception on executing command {"seq":44,"type":"request","command":"completionEntryDetails","arguments":{"file":"c:/code/TS/auto-import-default-bug/src/Baz.ts","line":8,"offset":13,"entryNames":[{"name":"Bar","source":"c:/code/TS/auto-import-default-bug/src/Bar","data":{"exportName":"Bar","fileName":"c:/code/TS/auto-import-default-bug/src/Bar.ts"}}]}}:

    Debug Failure. False expression.

    Error: Debug Failure. False expression.
        at collectAutoImports (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:125435:26)
        at getGlobalCompletions (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:125357:17)
        at tryGetGlobalSymbols (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:125263:25)
        at getCompletionData (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:125036:22)
        at getSymbolCompletionFromEntryId (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:124608:34)
        at Object.getCompletionEntryDetails (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:124640:36)
        at Proxy.getCompletionEntryDetails (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:154561:35)
        at c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:165834:57
        at Object.mapDefined (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:612:30)
        at IOSession.Session.getCompletionEntryDetails (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:165832:33)
        at Session.handlers.ts.Map.ts.getEntries._a.<computed> (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:164672:61)
        at c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:166452:88
        at IOSession.Session.executeWithRequestId (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:166443:28)
        at IOSession.Session.executeCommand (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:166452:33)
        at IOSession.Session.onMessage (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:166478:35)
        at Interface.<anonymous> (c:\code\TS\auto-import-default-bug\node_modules\typescript\lib\tsserver.js:169080:31)
        at Interface.emit (events.js:315:20)
        at Interface._onLine (readline.js:337:10)
        at Interface._normalWrite (readline.js:482:12)
        at Socket.ondata (readline.js:194:10)
        at Socket.emit (events.js:315:20)
        at addChunk (internal/streams/readable.js:309:12)
        at readableAddChunk (internal/streams/readable.js:284:9)
        at Socket.Readable.push (internal/streams/readable.js:223:10)
        at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

File text of c:/code/TS/auto-import-default-bug/src/Baz.ts:
    // import Bar from "./Bar"
    // import Foo from "./Foo"
    
    import Foo from "./Foo"
    
    class Baz {
        foo: Foo // Auto-importing this will work.
        bar: Bar // Then auto-importing this will fail.
    }

@andrewbranch
Copy link
Member

Hm, I wish I could reproduce this. It was likely fixed by accident in #44713, but seeing what caused it could have been useful. At any rate, the assertion now has a specific message about what went wrong, so if it continues to crash in the same place, we should be able to consolidate reports of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants