microsoft / microsoft/TypeScript

Intellisense not working for nested npm modules in node project with typings

Aperta
#40,121 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

  • VSCode Version: 1.48.0
  • Node.js: 12.8.1
  • OS Version: Windows_NT x64 10.0.18362

Steps to Reproduce:

  1. Git clone project from https://github.com/owenallenaz/vscode-test-project .
  2. Open project root folder in vscode .
  3. Go to nested containers/shared folder and npm install.
  4. Open containers/graphql/lib/testLib.js in vscode.
  5. Type hinting will exist for fs but not for lodash even though both are installed via their respective @types. Type hinting will work for p-memoize, but that project uses embedded d.ts files within the npm package itself, not provided via @types.

If you move the package.json down to the root of the project and delete typeRoots and paths, then the type hinting works perfect. The interesting thing you will note is that lodash will be listed as a found module. In example if you remove the "paths" block from tsconfig, then you will get the red squiggly under lodash. In addition, if you remove @types/node from package.json and npm install, you will find that the fs will no longer have type hinting. So the @types modules are working... but some aren't. I have observed this behavior for nearly every npm module I've tried, be it mongodb, express, lodash, none of them receive type hinting in this setup.

For technical reasons I cannot move the package.json to the project root because it's a multi-container Kubernetes project and the shared container does all of the NPM installs for the other containers.

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Clona il vscode-test-project collegato e riproduci il problema aprendo containers/graphql/lib/testLib.js dopo aver installato le dipendenze in containers/shared. Ispeziona il package.json annidato, typeRoots e paths in tsconfig confrontando la risoluzione di lodash, fs e p-memoize. Il lavoro è completato quando le definizioni dei tipi e IntelliSense vengono risolti per i moduli npm annidati installati tramite la configurazione del container condiviso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
nodejs, typescript, vscode
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.