microsoft / microsoft/TypeScript

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

Offen
#40,121 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs Investigation
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

  • 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Klone das verknüpfte vscode-test-project und reproduziere das Problem, indem du containers/graphql/lib/testLib.js öffnest, nachdem du die Abhängigkeiten in containers/shared installiert hast. Untersuche das verschachtelte package.json sowie typeRoots und paths in tsconfig und vergleiche dabei die Auflösung von lodash, fs und p-memoize. Erledigt ist die Aufgabe, wenn Typdefinitionen und IntelliSense für verschachtelte npm-Module aufgelöst werden, die über das gemeinsame Container-Setup installiert wurden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
nodejs, typescript, vscode
Bereich
developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.