microsoft / microsoft/TypeScript

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

Open
#40,121 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone the linked vscode-test-project and reproduce the issue by opening containers/graphql/lib/testLib.js after installing dependencies in containers/shared. Inspect the nested package.json, tsconfig typeRoots and paths while comparing lodash, fs, and p-memoize resolution. Done means typings and IntelliSense resolve for nested npm modules installed through the shared container setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.