You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Auto-import] Quick Fix suggests invalid module specifiers that fail to resolve at runtime #64171
Steps to reproduce:
In src/index.ts, start typing summarize.
Trigger the Quick Fix auto‑import suggestions.
🙁 Actual behavior
With the "node" condition active and "js/ts.preferences.importModuleSpecifier": "non-relative" set, the LSP (Quick Fix) offers two alias suggestions for the same symbol:
#utils/summarize - resolves correctly via "node" to ./dist/utils/summarize/index.js.
#utils/summarize/summarize - would resolve only via the "default" condition, which is not active at runtime.
Selecting the second suggestion causes a runtime error: node:internal/modules/esm/resolve:272 throw new ERR_MODULE_NOT_FOUND...
🙂 Expected behavior
Node.js uses only the first matching condition based on the active conditions.
The second alias is therefore never considered at runtime.
The auto‑import should suggest only valid module specifiers that matches the active conditions.
For example, both suggestions would be valid if the node condition were removed.
Additional information about the issue
The behavior is not limited to nodenext; it also occurs with other resolution modes and with customConditions.
Would not be a breaking change for LSP suggestions (Quick Fix / Auto Fix), as they would simply no longer offer specifiers that are unresolvable at runtime.
Update – additional case with paths in tsconfig.json
The issue also occurs when combining "imports" (in package.json) and "paths" (in tsconfig.json). For example:
With this setup, the Quick Fix suggests: import { summarize } from "#utils/summarize"; -> valid. import { summarize } from "#utils/summarize/summarize.js"; -> ERR_MODULE_NOT_FOUND
Activity