microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.09k stars 12.37k forks source link

Auto complete and auto import not work (ReactJS, ChakraUI) #59321

Closed TonyStark closed 1 month ago

TonyStark commented 1 month ago

Problem: I am developing react JS project with Chakra UI. When i try to type Box, Grid, GridItem or any other component of chakra ui, vs code cant auto complete or auto import those component from chakra ui module.

Screen Shot: Screenshot from 2024-07-17 11-49-44

Does this issue occur when all extensions are disabled?: Yes

VS Code Information:

Version: 1.91.1
Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
Date: 2024-07-09T22:08:12.169Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Linux x64 6.5.6-76060506-generic

Installed Extension:

ES7+ React/Redux/React-Native snippets
npm Intellisense
Prettier - Code formatter

TypeScript Version: 5.5.2

Steps to Reproduce:

  1. Installed VS Code. Installed reactJS, ChakraUI. Open Layout.jsx.
  2. I type "Gri" to check if it auto import/complete Grid component from ChakraUI
RyanCavanaugh commented 1 month ago

We need a project that reproduces the issue; this behavior may or may not be correct based on your configuration

TonyStark commented 1 month ago

@RyanCavanaugh Here you can clone repo >> https://github.com/TonyStark/vite-start-d15-CRUD-with-router

TonyStark commented 1 month ago

For fresh start i have created vite-project by using pnpm create vite > React > Javascript Later cd vite-project and installed chakra ui pnpm add @chakra-ui/react @emotion/react @emotion/styled framer-motion

RyanCavanaugh commented 1 month ago

TS Server log says

Info 1142 [15:22:35.143] AutoImportProviderProject: attempted to add more than 10 dependencies. Aborting.

You likely need to change this setting from "auto" to "on" and verify you don't have any exclusion patterns that would exclude the target files

Image

With proper configuration

Image

TonyStark commented 1 month ago

@RyanCavanaugh Hello, I set JSON Auto import as on and then restart vscode. but still not getting auto suggestion. Screenshot from 2024-07-27 09-21-22 i also scrolled through end, but no Grid components suggested in that

TonyStark commented 1 month ago

I think it happened in linux version only

RyanCavanaugh commented 1 month ago

We've never really had a Linux-specific auto-import bug. Did you also modify the path exclusion list?

TonyStark commented 1 month ago

this is my current settings, rest are as default

{
  "javascript.updateImportsOnFileMove.enabled": "always",
  "[javascriptreact]": {},
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "prettier.printWidth": 8000,
  "editor.minimap.enabled": false,
  "tabnine.experimentalAutoImports": true,
  "explorer.confirmDelete": false,
  "editor.multiCursorModifier": "ctrlCmd",
  "typescript.preferences.includePackageJsonAutoImports": "on"
}
typescript-bot commented 1 month ago

This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.