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
Run tsc --traceResolution and paste its output here
File 'C:/workspace/ts-test/src/package.json' does not exist.
Found 'package.json' at 'C:/workspace/ts-test/package.json'.
======== Resolving type reference directive 'dist', containing file 'C:/workspace/ts-test/__inferred type names__.ts', root directory 'C:/workspace/ts-test/@pkg1/a,C:/workspace/ts-test/@pkg2/b'. ========
Resolving with primary search path 'C:/workspace/ts-test/@pkg1/a, C:/workspace/ts-test/@pkg2/b'.
File 'C:/workspace/ts-test/@pkg1/a/dist.d.ts' does not exist.
File 'C:/workspace/ts-test/@pkg1/a/dist/package.json' does not exist.
File 'C:/workspace/ts-test/@pkg1/a/dist/index.d.ts' exists - use it as a name resolution result.
Resolving real path for 'C:/workspace/ts-test/@pkg1/a/dist/index.d.ts', result 'C:/workspace/ts-test/@pkg1/a/dist/index.d.ts'.
======== Type reference directive 'dist' was successfully resolved to 'C:/workspace/ts-test/@pkg1/a/dist/index.d.ts', primary: true. ========
File 'C:/workspace/ts-test/@pkg1/a/dist/package.json' does not exist according to earlier cached lookups.
Found 'package.json' at 'C:/workspace/ts-test/@pkg1/a/package.json'.
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist.
Found 'package.json' at 'C:/workspace/ts-test/node_modules/typescript/package.json'.
======== Resolving module '@typescript/lib-es5' from 'C:/workspace/ts-test/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory 'C:/workspace/ts-test/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-es5'
Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-es5' was not resolved. ========
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File 'C:/workspace/ts-test/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-decorators' from 'C:/workspace/ts-test/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory 'C:/workspace/ts-test/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators'
Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-decorators' was not resolved. ========
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File 'C:/workspace/ts-test/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-decorators/legacy' from 'C:/workspace/ts-test/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory 'C:/workspace/ts-test/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-decorators/legacy'
Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File 'C:/workspace/ts-test/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-dom' from 'C:/workspace/ts-test/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory 'C:/workspace/ts-test/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-dom'
Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-dom' was not resolved. ========
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File 'C:/workspace/ts-test/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-webworker/importscripts' from 'C:/workspace/ts-test/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory 'C:/workspace/ts-test/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-webworker/importscripts'
Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File 'C:/workspace/ts-test/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-scripthost' from 'C:/workspace/ts-test/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory 'C:/workspace/ts-test/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-scripthost'
Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory 'C:/workspace/node_modules' does not exist, skipping all lookups in it.
Directory 'C:/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-scripthost' was not resolved. ========
File 'C:/workspace/ts-test/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File 'C:/workspace/ts-test/node_modules/typescript/package.json' exists according to earlier cached lookups.
src/index.ts:4:17 - error TS2552: Cannot find name 'BType'. Did you mean 'AType'?
4 export const B: BType = "typeB";
~~~~~
Found 1 error in src/index.ts:4
Paste the package.json of the importing module, if it exists
Paste the package.json of the target module, if it exists
@pkg1/a/package.json
{
"name": "@pkg1/a",
"types": "dist/index.d.ts"
}
@pkg2/b/package.json
{
"name": "@pkg2/b",
"types": "dist/index.d.ts"
}
Any other comments can go here
There seems to be an issue when adding multiple typeRoots that have folders with the exact same name ("dist" in the example repo). The issue seems to be a that these folders will have the same to the key in the cache in the src/compiler/program.ts:loadWithModeAwareCache function.
Context for this issues
I'm a developer work on enabling the WebNN W3C specification in a project that requires both WebNN and WebGPU. If the WebNN CG creates a @webnn/types project based on the existing @webgpu/types, and developers include both typeRoots (i.e. "typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@webnn/types"]), developers would run into this issue.
The text was updated successfully, but these errors were encountered:
egalli
changed the title
Module resolution:
Module resolution: typeRoots key conflict in cache
Apr 29, 2024
When using types and the base project needs to override the default typeRoots, does that mean they they would need to add ./node_modules to the typeRoots. i.e.
{
"compilerOptions": {
"typeRoots": [
/* other project specific type roots */"./node_modules/"
],
"types": [
"@webgpu/types",
"@webnn/types"
]
}
}
Still, it seems kind of unexpected that different folders with the same name, but on different typeRoots, would be cache as the same module.
Demo Repo
https://github.com/egalli/type-root-test
Which of the following problems are you reporting?
Something else more complicated which I'll explain in more detail
Demonstrate the defect described above with a code sample.
src/index.ts
Run
tsc --showConfig
and paste its output hereRun
tsc --traceResolution
and paste its output herePaste the
package.json
of the importing module, if it existsPaste the
package.json
of the target module, if it exists@pkg1/a/package.json
@pkg2/b/package.json
Any other comments can go here
There seems to be an issue when adding multiple typeRoots that have folders with the exact same name ("dist" in the example repo). The issue seems to be a that these folders will have the same to the key in the cache in the
src/compiler/program.ts:loadWithModeAwareCache
function.Context for this issues
I'm a developer work on enabling the WebNN W3C specification in a project that requires both WebNN and WebGPU. If the WebNN CG creates a
@webnn/types
project based on the existing@webgpu/types
, and developers include both typeRoots (i.e."typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@webnn/types"]
), developers would run into this issue.The text was updated successfully, but these errors were encountered: