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 working inconsistently after updating to v1.60.1 #45921

Closed
IHIutch opened this issue Sep 16, 2021 · 8 comments
Closed

Auto import working inconsistently after updating to v1.60.1 #45921

IHIutch opened this issue Sep 16, 2021 · 8 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@IHIutch
Copy link

IHIutch commented Sep 16, 2021

TS Template added by @mjbvz

TypeScript Version: 4.4.2, 4.5.0-dev.20210915

Search Terms

  • auto import
  • completion / completions

@IHIutch Please open a separate issue with a minimal repo so we can investigate separately?

Originally posted by @mjbvz in microsoft/vscode#132299 (comment)

@IHIutch
Copy link
Author

IHIutch commented Sep 16, 2021

Here you go: https://github.com/IHIutch/auto-import-test

I also made a recording:
https://user-images.githubusercontent.com/20825047/133536156-6f4e487c-9a36-4708-885f-fcd181fb7fbb.mp4

It does look like the auto import works when you're using the specific package, but in previous VSCode versions, auto importing out of @chakra-ui/react worked.

This is VSCode 1.59.1:
https://user-images.githubusercontent.com/20825047/133536439-4b9b0c95-febe-4442-bf0a-e7ee3cbc32a3.mp4

Maybe this is an issue with how components are exported in certain packages, I did comment on a discussion in chakra-ui. chakra-ui/chakra-ui#4608 (comment)

So I guess Im trying to understand if this is a VSCode bug or a Chakra (and the like) bug. For full transparency, I know nothing about Typescript...

microsoft/vscode#132299 (comment)

@mjbvz
Copy link
Contributor

mjbvz commented Sep 16, 2021

Thanks! I can repo this locally. Will take a look

@mjbvz mjbvz transferred this issue from microsoft/vscode Sep 16, 2021
@mjbvz mjbvz removed their assignment Sep 16, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Sep 16, 2021

The error actually occurs in completionEntryDetails which prevents the import from being resolved properly:

Info 146  [15:08:47.870] request:
    {"seq":26,"type":"request","command":"completionEntryDetails","arguments":{"file":"/Users/matb/projects/san/auto-import-test/index.js","line":12,"offset":18,"entryNames":[{"name":"GridItem","source":"@chakra-ui/layout","data":{"exportName":"GridItem","fileName":"/Users/matb/projects/san/auto-import-test/node_modules/@chakra-ui/layout/dist/types/index.d.ts","moduleSpecifier":"@chakra-ui/layout"}}]}}
Err 147   [15:08:47.974] Exception on executing command {"seq":26,"type":"request","command":"completionEntryDetails","arguments":{"file":"/Users/matb/projects/san/auto-import-test/index.js","line":12,"offset":18,"entryNames":[{"name":"GridItem","source":"@chakra-ui/layout","data":{"exportName":"GridItem","fileName":"/Users/matb/projects/san/auto-import-test/node_modules/@chakra-ui/layout/dist/types/index.d.ts","moduleSpecifier":"@chakra-ui/layout"}}]}}:

    Debug Failure. False expression.

    Error: Debug Failure. False expression.
        at getCompletionEntryCodeActionsAndSourceDisplay (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:126516:22)
        at Object.getCompletionEntryDetails (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:126472:30)
        at Proxy.getCompletionEntryDetails (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:156798:35)
        at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:168262:57
        at Object.mapDefined (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:616:30)
        at IOSession.Session.getCompletionEntryDetails (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:168260:33)
        at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:167087:61)
        at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:168880:88
        at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:168871:28)
        at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:168880:33)
        at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:168906:35)
        at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:171511: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 /Users/matb/projects/san/auto-import-test/index.js:
    import React from "react";
    
    import { Grid } from "@chakra-ui/react";
    import { useForm } from "react-hook-form";
    
    export default function index() {
      const form = useForm();
    
      return (
        <Box>
          <Grid>
            <GridItem></GridItem>
          </Grid>
        </Box>
      );
    }

@andrewbranch
Copy link
Member

andrewbranch commented Sep 16, 2021

I would guess that #45792 fixes this, but it will be a bit before I can check. There is a packed version of that PR in the comments that someone can try if they’re curious.

@andrewbranch andrewbranch self-assigned this Oct 5, 2021
@andrewbranch andrewbranch added the Needs Investigation This issue needs a team member to investigate its status. label Oct 5, 2021
@andrewbranch andrewbranch added this to the TypeScript 4.5.1 milestone Oct 5, 2021
@andrewbranch
Copy link
Member

@IHIutch can you see if this is fixed in the nightly for you?

@yudyananda
Copy link

just test it with nightly v4.5.20211013 auto import still not respecting the correct path

chakra_auto

@andrewbranch
Copy link
Member

That’s a different issue; @chakra-ui/layout uses an export map and they need to update their package.json to be compatible. See #46281 and #46334. The issue in question here is the crash with the stack trace seen above.

@andrewbranch
Copy link
Member

Closing for now, if someone can repro the same crash in nightly, let me know and I’ll reopen. I wasn’t able to repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

4 participants