From 85bce61a6b9e3cc5f67a67c15e5824f210caf6e1 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 15:54:09 -0700 Subject: [PATCH 1/9] Test case --- .../typeReferenceDirectiveWithTypeAsFile.errors.txt | 13 +++++++++++++ .../typeReferenceDirectiveWithTypeAsFile.js | 11 +++++++++++ .../typeReferenceDirectiveWithTypeAsFile.symbols | 4 ++++ .../typeReferenceDirectiveWithTypeAsFile.trace.json | 10 ++++++++++ .../typeReferenceDirectiveWithTypeAsFile.types | 4 ++++ .../typeReferenceDirectiveWithTypeAsFile.ts | 11 +++++++++++ 6 files changed, 53 insertions(+) create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types create mode 100644 tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt new file mode 100644 index 0000000000000..0b2fce5e28f65 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt @@ -0,0 +1,13 @@ +error TS2688: Cannot find type definition file for 'phaser'. +/a.ts(1,1): error TS2304: Cannot find name 'a'. + + +!!! error TS2688: Cannot find type definition file for 'phaser'. +==== /a.ts (1 errors) ==== + a; + ~ +!!! error TS2304: Cannot find name 'a'. + +==== /node_modules/phaser/types/phaser.d.ts (0 errors) ==== + declare const a: number; + \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js new file mode 100644 index 0000000000000..58a1fb047d8b2 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts] //// + +//// [phaser.d.ts] +declare const a: number; + +//// [a.ts] +a; + + +//// [a.js] +a; diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols new file mode 100644 index 0000000000000..d567da2a8cdb6 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols @@ -0,0 +1,4 @@ +=== /a.ts === +a; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json new file mode 100644 index 0000000000000..e3c356a07350d --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json @@ -0,0 +1,10 @@ +[ + "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/node_modules/phaser/types'. ========", + "Resolving with primary search path '/node_modules/phaser/types'.", + "Looking up in 'node_modules' folder, initial location '/'.", + "File '/node_modules/phaser/package.json' does not exist.", + "File '/node_modules/phaser.d.ts' does not exist.", + "File '/node_modules/phaser/index.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "======== Type reference directive 'phaser' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types new file mode 100644 index 0000000000000..2ec6ffcf1be41 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types @@ -0,0 +1,4 @@ +=== /a.ts === +a; +>a : any + diff --git a/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts b/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts new file mode 100644 index 0000000000000..cf9abfeab602b --- /dev/null +++ b/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts @@ -0,0 +1,11 @@ +// @noImplicitReferences: true +// @typeRoots: /node_modules/phaser/types +// @types: phaser +// @traceResolution: true +// @currentDirectory: / + +// @Filename: /node_modules/phaser/types/phaser.d.ts +declare const a: number; + +// @Filename: /a.ts +a; From 892f214d49640525308bc537885502175a96843d Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 16:00:52 -0700 Subject: [PATCH 2/9] Resolve typeReferenceDirective as fileOrDirectory instead of just directory Fixes #37708 Bug 2 part of the issue --- src/compiler/moduleNameResolver.ts | 16 ++++++++-------- ...peReferenceDirectiveWithTypeAsFile.errors.txt | 13 ------------- .../typeReferenceDirectiveWithTypeAsFile.symbols | 8 ++++++-- ...peReferenceDirectiveWithTypeAsFile.trace.json | 9 ++++----- .../typeReferenceDirectiveWithTypeAsFile.types | 6 +++++- 5 files changed, 23 insertions(+), 29 deletions(-) delete mode 100644 tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ad331c60be7f2..6c200c7fe0223 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -343,15 +343,15 @@ namespace ts { trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } return firstDefined(typeRoots, typeRoot => { - const candidate = combinePaths(typeRoot, typeReferenceDirectiveName); - const candidateDirectory = getDirectoryPath(candidate); - const directoryExists = directoryProbablyExists(candidateDirectory, host); - if (!directoryExists && traceEnabled) { - trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); - } return resolvedTypeScriptOnly( - loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, - !directoryExists, moduleResolutionState)); + nodeLoadModuleByRelativeName( + Extensions.DtsOnly, + combinePaths(typeRoot, typeReferenceDirectiveName), + /*onlyRecordFailures*/ false, + moduleResolutionState, + /*considerPackageJson*/ true + ) + ); }); } else { diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt deleted file mode 100644 index 0b2fce5e28f65..0000000000000 --- a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -error TS2688: Cannot find type definition file for 'phaser'. -/a.ts(1,1): error TS2304: Cannot find name 'a'. - - -!!! error TS2688: Cannot find type definition file for 'phaser'. -==== /a.ts (1 errors) ==== - a; - ~ -!!! error TS2304: Cannot find name 'a'. - -==== /node_modules/phaser/types/phaser.d.ts (0 errors) ==== - declare const a: number; - \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols index d567da2a8cdb6..f29a1bafe2741 100644 --- a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols @@ -1,4 +1,8 @@ === /a.ts === a; -No type information for this code. -No type information for this code. \ No newline at end of file +>a : Symbol(a, Decl(phaser.d.ts, 0, 13)) + +=== /node_modules/phaser/types/phaser.d.ts === +declare const a: number; +>a : Symbol(a, Decl(phaser.d.ts, 0, 13)) + diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json index e3c356a07350d..8a4576bb9ee22 100644 --- a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json @@ -1,10 +1,9 @@ [ "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/node_modules/phaser/types'. ========", "Resolving with primary search path '/node_modules/phaser/types'.", - "Looking up in 'node_modules' folder, initial location '/'.", + "Loading module as file / folder, candidate module location '/node_modules/phaser/types/phaser', target file type 'DtsOnly'.", + "File '/node_modules/phaser/types/phaser.d.ts' exist - use it as a name resolution result.", "File '/node_modules/phaser/package.json' does not exist.", - "File '/node_modules/phaser.d.ts' does not exist.", - "File '/node_modules/phaser/index.d.ts' does not exist.", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "======== Type reference directive 'phaser' was not resolved. ========" + "Resolving real path for '/node_modules/phaser/types/phaser.d.ts', result '/node_modules/phaser/types/phaser.d.ts'.", + "======== Type reference directive 'phaser' was successfully resolved to '/node_modules/phaser/types/phaser.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types index 2ec6ffcf1be41..20416fc921d6d 100644 --- a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types +++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types @@ -1,4 +1,8 @@ === /a.ts === a; ->a : any +>a : number + +=== /node_modules/phaser/types/phaser.d.ts === +declare const a: number; +>a : number From 27191d5b3a199afd9bacd0a3ffaa648ed7374726 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 16:46:05 -0700 Subject: [PATCH 3/9] Fix existing baseline Part1 --- .../works-when-module-resolution-changes-to-ambient-module.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/baselines/reference/tscWatch/resolutionCache/works-when-module-resolution-changes-to-ambient-module.js b/tests/baselines/reference/tscWatch/resolutionCache/works-when-module-resolution-changes-to-ambient-module.js index e374a0d0dc510..b9a74924dc757 100644 --- a/tests/baselines/reference/tscWatch/resolutionCache/works-when-module-resolution-changes-to-ambient-module.js +++ b/tests/baselines/reference/tscWatch/resolutionCache/works-when-module-resolution-changes-to-ambient-module.js @@ -114,6 +114,8 @@ WatchedFiles:: FsWatches:: FsWatchesRecursive:: +/a/b/node_modules: + {"directoryName":"/a/b/node_modules","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} /a/b/node_modules/@types: {"directoryName":"/a/b/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} From 4c77eb92fe8972a05966c62a8cfc2fb574ae8f58 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 16:46:30 -0700 Subject: [PATCH 4/9] Baseline traceResolution traces from reuseProgramStructure Fixes existing baseline as well (part2) --- .../unittests/reuseProgramStructure.ts | 242 +++--------------- ...rations-from-non-modified-files.trace.json | 63 +++++ ...lutions-from-non-modified-files.trace.json | 114 +++++++++ ...tches-imports-after-npm-install.trace.json | 37 +++ 4 files changed, 245 insertions(+), 211 deletions(-) create mode 100644 tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.trace.json create mode 100644 tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.trace.json create mode 100644 tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.trace.json diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts index 8c3f9d6a94fb7..5f410eedd2b9e 100644 --- a/src/testRunner/unittests/reuseProgramStructure.ts +++ b/src/testRunner/unittests/reuseProgramStructure.ts @@ -210,6 +210,18 @@ namespace ts { checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective); } + type Traces = [subScenario: string, program: ProgramWithSourceTexts][]; + function baselineTrace(scenario: string, traces: Traces) { + const actual: MapLike = {}; + for (const [subScenario, program] of traces) { + actual[subScenario] = program.host.getTrace().map(Utils.sanitizeTraceResolutionLogEntry); + } + Harness.Baseline.runBaseline( + `reuseProgramStructure/${scenario.split(" ").join("-")}.trace.json`, + JSON.stringify(actual, undefined, 4) + ); + } + describe("unittests:: Reuse program structure:: General", () => { const target = ScriptTarget.Latest; const files: NamedSourceText[] = [ @@ -455,34 +467,11 @@ namespace ts { const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.NodeJs }; const rootFiles = [file1Ts, file2Ts]; const filesAfterNpmInstall = [file1Ts, file2Ts, indexDTS]; + const traces: Traces = []; const initialProgram = newProgram(rootFiles, rootFiles.map(f => f.name), options); { - assert.deepEqual(initialProgram.host.getTrace(), - [ - "======== Resolving module 'a' from 'file1.ts'. ========", - "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", - "File 'node_modules/a/package.json' does not exist.", - "File 'node_modules/a.ts' does not exist.", - "File 'node_modules/a.tsx' does not exist.", - "File 'node_modules/a.d.ts' does not exist.", - "File 'node_modules/a/index.ts' does not exist.", - "File 'node_modules/a/index.tsx' does not exist.", - "File 'node_modules/a/index.d.ts' does not exist.", - "File 'node_modules/@types/a/package.json' does not exist.", - "File 'node_modules/@types/a.d.ts' does not exist.", - "File 'node_modules/@types/a/index.d.ts' does not exist.", - "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", - "File 'node_modules/a/package.json' does not exist.", - "File 'node_modules/a.js' does not exist.", - "File 'node_modules/a.jsx' does not exist.", - "File 'node_modules/a/index.js' does not exist.", - "File 'node_modules/a/index.jsx' does not exist.", - "======== Module name 'a' was not resolved. ========" - ], - "initialProgram: execute module resolution normally."); - + traces.push(["initialProgram: execute module resolution normally.", initialProgram]); const initialProgramDiagnostics = initialProgram.getSemanticDiagnostics(initialProgram.getSourceFile("file1.ts")); assert.lengthOf(initialProgramDiagnostics, 1, `initialProgram: import should fail.`); } @@ -491,25 +480,12 @@ namespace ts { f[1].text = f[1].text.updateReferences(`/// `); }, filesAfterNpmInstall); { - assert.deepEqual(afterNpmInstallProgram.host.getTrace(), - [ - "======== Resolving module 'a' from 'file1.ts'. ========", - "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", - "File 'node_modules/a/package.json' does not exist.", - "File 'node_modules/a.ts' does not exist.", - "File 'node_modules/a.tsx' does not exist.", - "File 'node_modules/a.d.ts' does not exist.", - "File 'node_modules/a/index.ts' does not exist.", - "File 'node_modules/a/index.tsx' does not exist.", - "File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.", - "======== Module name 'a' was successfully resolved to 'node_modules/a/index.d.ts'. ========" - ], - "afterNpmInstallProgram: execute module resolution normally."); - + traces.push(["afterNpmInstallProgram: execute module resolution normally.", afterNpmInstallProgram]); const afterNpmInstallProgramDiagnostics = afterNpmInstallProgram.getSemanticDiagnostics(afterNpmInstallProgram.getSourceFile("file1.ts")); assert.lengthOf(afterNpmInstallProgramDiagnostics, 0, `afterNpmInstallProgram: program is well-formed with import.`); } + + baselineTrace("fetches imports after npm install", traces); }); it("can reuse ambient module declarations from non-modified files", () => { @@ -519,78 +495,19 @@ namespace ts { ]; const options = { target: ScriptTarget.ES2015, traceResolution: true }; const program = newProgram(files, files.map(f => f.name), options); - assert.deepEqual(program.host.getTrace(), - [ - "======== Resolving module 'fs' from '/a/b/app.ts'. ========", - "Module resolution kind is not specified, using 'Classic'.", - "File '/a/b/fs.ts' does not exist.", - "File '/a/b/fs.tsx' does not exist.", - "File '/a/b/fs.d.ts' does not exist.", - "File '/a/fs.ts' does not exist.", - "File '/a/fs.tsx' does not exist.", - "File '/a/fs.d.ts' does not exist.", - "File '/fs.ts' does not exist.", - "File '/fs.tsx' does not exist.", - "File '/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs/package.json' does not exist.", - "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/node_modules/@types/fs/package.json' does not exist.", - "File '/a/node_modules/@types/fs.d.ts' does not exist.", - "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/node_modules/@types/fs/package.json' does not exist.", - "File '/node_modules/@types/fs.d.ts' does not exist.", - "File '/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/b/fs.js' does not exist.", - "File '/a/b/fs.jsx' does not exist.", - "File '/a/fs.js' does not exist.", - "File '/a/fs.jsx' does not exist.", - "File '/fs.js' does not exist.", - "File '/fs.jsx' does not exist.", - "======== Module name 'fs' was not resolved. ========", - ], "should look for 'fs'"); + const traces: Traces = []; + traces.push(["should look for 'fs'.", program]); const program2 = updateProgram(program, program.getRootFileNames(), options, f => { f[0].text = f[0].text.updateProgram("var x = 1;"); }); - assert.deepEqual(program2.host.getTrace(), [ - "Module 'fs' was resolved as ambient module declared in '/a/b/node.d.ts' since this file was not modified." - ], "should reuse 'fs' since node.d.ts was not changed"); - + traces.push(["should reuse 'fs' since node.d.ts was not changed", program2]); const program3 = updateProgram(program2, program2.getRootFileNames(), options, f => { f[0].text = f[0].text.updateProgram("var y = 1;"); f[1].text = f[1].text.updateProgram("declare var process: any"); }); - assert.deepEqual(program3.host.getTrace(), - [ - "======== Resolving module 'fs' from '/a/b/app.ts'. ========", - "Module resolution kind is not specified, using 'Classic'.", - "File '/a/b/fs.ts' does not exist.", - "File '/a/b/fs.tsx' does not exist.", - "File '/a/b/fs.d.ts' does not exist.", - "File '/a/fs.ts' does not exist.", - "File '/a/fs.tsx' does not exist.", - "File '/a/fs.d.ts' does not exist.", - "File '/fs.ts' does not exist.", - "File '/fs.tsx' does not exist.", - "File '/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs/package.json' does not exist.", - "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/node_modules/@types/fs/package.json' does not exist.", - "File '/a/node_modules/@types/fs.d.ts' does not exist.", - "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/node_modules/@types/fs/package.json' does not exist.", - "File '/node_modules/@types/fs.d.ts' does not exist.", - "File '/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/b/fs.js' does not exist.", - "File '/a/b/fs.jsx' does not exist.", - "File '/a/fs.js' does not exist.", - "File '/a/fs.jsx' does not exist.", - "File '/fs.js' does not exist.", - "File '/fs.jsx' does not exist.", - "======== Module name 'fs' was not resolved. ========", - ], "should look for 'fs' again since node.d.ts was changed"); + traces.push(["should look for 'fs' again since node.d.ts was changed", program3]); + baselineTrace("can reuse ambient module declarations from non-modified files", traces); }); it("can reuse module resolutions from non-modified files", () => { @@ -617,38 +534,12 @@ namespace ts { "(new BB).x; (new BB).y;") }, ]; - + const traces: Traces = []; const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.Classic }; const program1 = newProgram(files, files.map(f => f.name), options); let expectedErrors = 0; { - assert.deepEqual(program1.host.getTrace(), - [ - "======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs1/package.json' does not exist.", - "File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========", - "======== Resolving module './b1' from 'f1.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b1.ts' exist - use it as a name resolution result.", - "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", - "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs2/package.json' does not exist.", - "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", - "======== Resolving module './b2' from 'f2.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b2.ts' exist - use it as a name resolution result.", - "======== Module name './b2' was successfully resolved to 'b2.ts'. ========", - "======== Resolving module './f1' from 'f2.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'f1.ts' exist - use it as a name resolution result.", - "======== Module name './f1' was successfully resolved to 'f1.ts'. ========" - ], - "program1: execute module resolution normally."); - + traces.push(["program1: execute module resolution normally.", program1]); const program1Diagnostics = program1.getSemanticDiagnostics(program1.getSourceFile("f2.ts")); assert.lengthOf(program1Diagnostics, expectedErrors, `initial program should be well-formed`); } @@ -661,25 +552,7 @@ namespace ts { { const program2Diagnostics = program2.getSemanticDiagnostics(program2.getSourceFile("f2.ts")); assert.lengthOf(program2Diagnostics, expectedErrors, `removing no-default-lib shouldn't affect any types used.`); - - assert.deepEqual(program2.host.getTrace(), [ - "======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs1/package.json' does not exist.", - "File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========", - "======== Resolving module './b1' from 'f1.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b1.ts' exist - use it as a name resolution result.", - "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", - "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs2/package.json' does not exist.", - "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", - "Reusing resolution of module './b2' to file 'f2.ts' from old program.", - "Reusing resolution of module './f1' to file 'f2.ts' from old program." - ], "program2: reuse module resolutions in f2 since it is unchanged"); + traces.push(["program2: reuse module resolutions in f2 since it is unchanged", program2]); } const program3 = updateProgram(program2, program2.getRootFileNames(), options, f => { @@ -690,20 +563,7 @@ namespace ts { { const program3Diagnostics = program3.getSemanticDiagnostics(program3.getSourceFile("f2.ts")); assert.lengthOf(program3Diagnostics, expectedErrors, `typerefs2 was unused, so diagnostics should be unaffected.`); - - assert.deepEqual(program3.host.getTrace(), [ - "======== Resolving module './b1' from 'f1.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b1.ts' exist - use it as a name resolution result.", - "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", - "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs2/package.json' does not exist.", - "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", - "Reusing resolution of module './b2' to file 'f2.ts' from old program.", - "Reusing resolution of module './f1' to file 'f2.ts' from old program." - ], "program3: reuse module resolutions in f2 since it is unchanged"); + traces.push(["program3: reuse module resolutions in f2 since it is unchanged", program3]); } @@ -715,20 +575,7 @@ namespace ts { { const program4Diagnostics = program4.getSemanticDiagnostics(program4.getSourceFile("f2.ts")); assert.lengthOf(program4Diagnostics, expectedErrors, `a1.ts was unused, so diagnostics should be unaffected.`); - - assert.deepEqual(program4.host.getTrace(), [ - "======== Resolving module './b1' from 'f1.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b1.ts' exist - use it as a name resolution result.", - "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", - "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs2/package.json' does not exist.", - "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", - "Reusing resolution of module './b2' to file 'f2.ts' from old program.", - "Reusing resolution of module './f1' to file 'f2.ts' from old program." - ], "program_4: reuse module resolutions in f2 since it is unchanged"); + traces.push(["program_4: reuse module resolutions in f2 since it is unchanged", program4]); } const program5 = updateProgram(program4, program4.getRootFileNames(), options, f => { @@ -739,13 +586,7 @@ namespace ts { { const program5Diagnostics = program5.getSemanticDiagnostics(program5.getSourceFile("f2.ts")); assert.lengthOf(program5Diagnostics, ++expectedErrors, `import of BB in f1 fails. BB is of type any. Add one error`); - - assert.deepEqual(program5.host.getTrace(), [ - "======== Resolving module './b1' from 'f1.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b1.ts' exist - use it as a name resolution result.", - "======== Module name './b1' was successfully resolved to 'b1.ts'. ========" - ], "program_5: exports do not affect program structure, so f2's resolutions are silently reused."); + traces.push(["program_5: exports do not affect program structure, so f2's resolutions are silently reused.", program5]); } const program6 = updateProgram(program5, program5.getRootFileNames(), options, f => { @@ -756,20 +597,7 @@ namespace ts { { const program6Diagnostics = program6.getSemanticDiagnostics(program6.getSourceFile("f2.ts")); assert.lengthOf(program6Diagnostics, expectedErrors, `import of BB in f1 fails.`); - - assert.deepEqual(program6.host.getTrace(), [ - "======== Resolving module './b1' from 'f1.ts'. ========", - "Explicitly specified module resolution kind: 'Classic'.", - "File 'b1.ts' exist - use it as a name resolution result.", - "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", - "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs2/package.json' does not exist.", - "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", - "Reusing resolution of module './b2' to file 'f2.ts' from old program.", - "Reusing resolution of module './f1' to file 'f2.ts' from old program." - ], "program_6: reuse module resolutions in f2 since it is unchanged"); + traces.push(["program_6: reuse module resolutions in f2 since it is unchanged", program6]); } const program7 = updateProgram(program6, program6.getRootFileNames(), options, f => { @@ -780,17 +608,9 @@ namespace ts { { const program7Diagnostics = program7.getSemanticDiagnostics(program7.getSourceFile("f2.ts")); assert.lengthOf(program7Diagnostics, expectedErrors, `removing import is noop with respect to program, so no change in diagnostics.`); - - assert.deepEqual(program7.host.getTrace(), [ - "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", - "Resolving with primary search path 'node_modules/@types'.", - "File 'node_modules/@types/typerefs2/package.json' does not exist.", - "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", - "Reusing resolution of module './b2' to file 'f2.ts' from old program.", - "Reusing resolution of module './f1' to file 'f2.ts' from old program." - ], "program_7 should reuse module resolutions in f2 since it is unchanged"); + traces.push(["program_7 should reuse module resolutions in f2 since it is unchanged", program7]); } + baselineTrace("can reuse module resolutions from non-modified files", traces); }); describe("redirects", () => { diff --git a/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.trace.json b/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.trace.json new file mode 100644 index 0000000000000..68e24eb905056 --- /dev/null +++ b/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.trace.json @@ -0,0 +1,63 @@ +{ + "should look for 'fs'.": [ + "======== Resolving module 'fs' from '/a/b/app.ts'. ========", + "Module resolution kind is not specified, using 'Classic'.", + "File '/a/b/fs.ts' does not exist.", + "File '/a/b/fs.tsx' does not exist.", + "File '/a/b/fs.d.ts' does not exist.", + "File '/a/fs.ts' does not exist.", + "File '/a/fs.tsx' does not exist.", + "File '/a/fs.d.ts' does not exist.", + "File '/fs.ts' does not exist.", + "File '/fs.tsx' does not exist.", + "File '/fs.d.ts' does not exist.", + "File '/a/b/node_modules/@types/fs/package.json' does not exist.", + "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", + "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", + "File '/a/node_modules/@types/fs/package.json' does not exist.", + "File '/a/node_modules/@types/fs.d.ts' does not exist.", + "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", + "File '/node_modules/@types/fs/package.json' does not exist.", + "File '/node_modules/@types/fs.d.ts' does not exist.", + "File '/node_modules/@types/fs/index.d.ts' does not exist.", + "File '/a/b/fs.js' does not exist.", + "File '/a/b/fs.jsx' does not exist.", + "File '/a/fs.js' does not exist.", + "File '/a/fs.jsx' does not exist.", + "File '/fs.js' does not exist.", + "File '/fs.jsx' does not exist.", + "======== Module name 'fs' was not resolved. ========" + ], + "should reuse 'fs' since node.d.ts was not changed": [ + "Module 'fs' was resolved as ambient module declared in '/a/b/node.d.ts' since this file was not modified." + ], + "should look for 'fs' again since node.d.ts was changed": [ + "======== Resolving module 'fs' from '/a/b/app.ts'. ========", + "Module resolution kind is not specified, using 'Classic'.", + "File '/a/b/fs.ts' does not exist.", + "File '/a/b/fs.tsx' does not exist.", + "File '/a/b/fs.d.ts' does not exist.", + "File '/a/fs.ts' does not exist.", + "File '/a/fs.tsx' does not exist.", + "File '/a/fs.d.ts' does not exist.", + "File '/fs.ts' does not exist.", + "File '/fs.tsx' does not exist.", + "File '/fs.d.ts' does not exist.", + "File '/a/b/node_modules/@types/fs/package.json' does not exist.", + "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", + "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", + "File '/a/node_modules/@types/fs/package.json' does not exist.", + "File '/a/node_modules/@types/fs.d.ts' does not exist.", + "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", + "File '/node_modules/@types/fs/package.json' does not exist.", + "File '/node_modules/@types/fs.d.ts' does not exist.", + "File '/node_modules/@types/fs/index.d.ts' does not exist.", + "File '/a/b/fs.js' does not exist.", + "File '/a/b/fs.jsx' does not exist.", + "File '/a/fs.js' does not exist.", + "File '/a/fs.jsx' does not exist.", + "File '/fs.js' does not exist.", + "File '/fs.jsx' does not exist.", + "======== Module name 'fs' was not resolved. ========" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.trace.json b/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.trace.json new file mode 100644 index 0000000000000..68412e57eeb7b --- /dev/null +++ b/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.trace.json @@ -0,0 +1,114 @@ +{ + "program1: execute module resolution normally.": [ + "======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs1', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs1.d.ts' does not exist.", + "File 'node_modules/@types/typerefs1/package.json' does not exist.", + "File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========", + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs2.d.ts' does not exist.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "======== Resolving module './b2' from 'f2.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b2.ts' exist - use it as a name resolution result.", + "======== Module name './b2' was successfully resolved to 'b2.ts'. ========", + "======== Resolving module './f1' from 'f2.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'f1.ts' exist - use it as a name resolution result.", + "======== Module name './f1' was successfully resolved to 'f1.ts'. ========" + ], + "program2: reuse module resolutions in f2 since it is unchanged": [ + "======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs1', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs1.d.ts' does not exist.", + "File 'node_modules/@types/typerefs1/package.json' does not exist.", + "File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========", + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs2.d.ts' does not exist.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], + "program3: reuse module resolutions in f2 since it is unchanged": [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs2.d.ts' does not exist.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], + "program_4: reuse module resolutions in f2 since it is unchanged": [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs2.d.ts' does not exist.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], + "program_5: exports do not affect program structure, so f2's resolutions are silently reused.": [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========" + ], + "program_6: reuse module resolutions in f2 since it is unchanged": [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs2.d.ts' does not exist.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], + "program_7 should reuse module resolutions in f2 since it is unchanged": [ + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.", + "File 'node_modules/@types/typerefs2.d.ts' does not exist.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.trace.json b/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.trace.json new file mode 100644 index 0000000000000..eb08ed9ff9e51 --- /dev/null +++ b/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.trace.json @@ -0,0 +1,37 @@ +{ + "initialProgram: execute module resolution normally.": [ + "======== Resolving module 'a' from 'file1.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a/package.json' does not exist.", + "File 'node_modules/a.ts' does not exist.", + "File 'node_modules/a.tsx' does not exist.", + "File 'node_modules/a.d.ts' does not exist.", + "File 'node_modules/a/index.ts' does not exist.", + "File 'node_modules/a/index.tsx' does not exist.", + "File 'node_modules/a/index.d.ts' does not exist.", + "File 'node_modules/@types/a/package.json' does not exist.", + "File 'node_modules/@types/a.d.ts' does not exist.", + "File 'node_modules/@types/a/index.d.ts' does not exist.", + "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", + "File 'node_modules/a/package.json' does not exist.", + "File 'node_modules/a.js' does not exist.", + "File 'node_modules/a.jsx' does not exist.", + "File 'node_modules/a/index.js' does not exist.", + "File 'node_modules/a/index.jsx' does not exist.", + "======== Module name 'a' was not resolved. ========" + ], + "afterNpmInstallProgram: execute module resolution normally.": [ + "======== Resolving module 'a' from 'file1.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a/package.json' does not exist.", + "File 'node_modules/a.ts' does not exist.", + "File 'node_modules/a.tsx' does not exist.", + "File 'node_modules/a.d.ts' does not exist.", + "File 'node_modules/a/index.ts' does not exist.", + "File 'node_modules/a/index.tsx' does not exist.", + "File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.", + "======== Module name 'a' was successfully resolved to 'node_modules/a/index.d.ts'. ========" + ] +} \ No newline at end of file From 8a07917b6741f14e2413223a560f6cb30dc51bf3 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 17:08:26 -0700 Subject: [PATCH 5/9] Remaining baseline changes --- .../reference/library-reference-1.trace.json | 4 ++++ .../reference/library-reference-10.trace.json | 4 ++++ .../reference/library-reference-13.trace.json | 2 ++ .../reference/library-reference-14.trace.json | 2 ++ .../reference/library-reference-15.trace.json | 2 ++ .../reference/library-reference-2.trace.json | 4 ++++ .../reference/library-reference-4.trace.json | 12 ++++++++++++ .../reference/library-reference-5.trace.json | 4 ++++ .../reference/library-reference-6.trace.json | 4 ++++ .../reference/library-reference-8.trace.json | 12 ++++++++++++ .../library-reference-scoped-packages.trace.json | 1 + .../reference/typeReferenceDirectives1.trace.json | 4 ++++ .../reference/typeReferenceDirectives10.trace.json | 4 ++++ .../reference/typeReferenceDirectives11.trace.json | 2 ++ .../reference/typeReferenceDirectives12.trace.json | 4 ++++ .../reference/typeReferenceDirectives13.trace.json | 4 ++++ .../reference/typeReferenceDirectives2.trace.json | 2 ++ .../reference/typeReferenceDirectives3.trace.json | 4 ++++ .../reference/typeReferenceDirectives4.trace.json | 4 ++++ .../reference/typeReferenceDirectives5.trace.json | 4 ++++ .../reference/typeReferenceDirectives6.trace.json | 4 ++++ .../reference/typeReferenceDirectives7.trace.json | 4 ++++ .../reference/typeReferenceDirectives8.trace.json | 2 ++ .../reference/typeReferenceDirectives9.trace.json | 4 ++++ ...ootsFromMultipleNodeModulesDirectories.trace.json | 9 +++++++++ ...eRootsFromNodeModulesInParentDirectory.trace.json | 2 ++ tests/baselines/reference/typingsLookup1.trace.json | 4 ++++ tests/baselines/reference/typingsLookup3.trace.json | 4 ++++ tests/baselines/reference/typingsLookup4.trace.json | 8 ++++++++ .../baselines/reference/typingsLookupAmd.trace.json | 2 ++ 30 files changed, 126 insertions(+) diff --git a/tests/baselines/reference/library-reference-1.trace.json b/tests/baselines/reference/library-reference-1.trace.json index b09781aa3f435..622b293c00aaa 100644 --- a/tests/baselines/reference/library-reference-1.trace.json +++ b/tests/baselines/reference/library-reference-1.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/jquery', target file type 'DtsOnly'.", + "File 'types/jquery.d.ts' does not exist.", "File 'types/jquery/package.json' does not exist.", "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/types/jquery/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/src/__inferred type names__.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/jquery', target file type 'DtsOnly'.", + "File 'types/jquery.d.ts' does not exist.", "File 'types/jquery/package.json' does not exist.", "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.", diff --git a/tests/baselines/reference/library-reference-10.trace.json b/tests/baselines/reference/library-reference-10.trace.json index 92b5b03507978..83fbefa2463ad 100644 --- a/tests/baselines/reference/library-reference-10.trace.json +++ b/tests/baselines/reference/library-reference-10.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'jquery', containing file '/foo/consumer.ts', root directory './types'. ========", "Resolving with primary search path './types'.", + "Loading module as file / folder, candidate module location './types/jquery', target file type 'DtsOnly'.", + "File './types/jquery.d.ts' does not exist.", "Found 'package.json' at './types/jquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.", @@ -9,6 +11,8 @@ "======== Type reference directive 'jquery' was successfully resolved to '/foo/types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/foo/__inferred type names__.ts', root directory './types'. ========", "Resolving with primary search path './types'.", + "Loading module as file / folder, candidate module location './types/jquery', target file type 'DtsOnly'.", + "File './types/jquery.d.ts' does not exist.", "Found 'package.json' at './types/jquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-13.trace.json b/tests/baselines/reference/library-reference-13.trace.json index 70ebb87589937..ab608db0b7980 100644 --- a/tests/baselines/reference/library-reference-13.trace.json +++ b/tests/baselines/reference/library-reference-13.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========", "Resolving with primary search path '/a/types'.", + "Loading module as file / folder, candidate module location '/a/types/jquery', target file type 'DtsOnly'.", + "File '/a/types/jquery.d.ts' does not exist.", "File '/a/types/jquery/package.json' does not exist.", "File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/a/types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.", diff --git a/tests/baselines/reference/library-reference-14.trace.json b/tests/baselines/reference/library-reference-14.trace.json index 70ebb87589937..ab608db0b7980 100644 --- a/tests/baselines/reference/library-reference-14.trace.json +++ b/tests/baselines/reference/library-reference-14.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========", "Resolving with primary search path '/a/types'.", + "Loading module as file / folder, candidate module location '/a/types/jquery', target file type 'DtsOnly'.", + "File '/a/types/jquery.d.ts' does not exist.", "File '/a/types/jquery/package.json' does not exist.", "File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/a/types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.", diff --git a/tests/baselines/reference/library-reference-15.trace.json b/tests/baselines/reference/library-reference-15.trace.json index 0f76cf52984c7..bb6a9db75a10b 100644 --- a/tests/baselines/reference/library-reference-15.trace.json +++ b/tests/baselines/reference/library-reference-15.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/jquery', target file type 'DtsOnly'.", + "File 'types/jquery.d.ts' does not exist.", "File 'types/jquery/package.json' does not exist.", "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.", diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index d4f509900056d..14341b9cb0018 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/jquery', target file type 'DtsOnly'.", + "File '/types/jquery.d.ts' does not exist.", "Found 'package.json' at '/types/jquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' does not have a 'typings' field.", @@ -10,6 +12,8 @@ "======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/jquery', target file type 'DtsOnly'.", + "File '/types/jquery.d.ts' does not exist.", "Found 'package.json' at '/types/jquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' does not have a 'typings' field.", diff --git a/tests/baselines/reference/library-reference-4.trace.json b/tests/baselines/reference/library-reference-4.trace.json index ceeb754bb0bdd..f9a72f22c33e4 100644 --- a/tests/baselines/reference/library-reference-4.trace.json +++ b/tests/baselines/reference/library-reference-4.trace.json @@ -1,6 +1,9 @@ [ "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", + "Loading module as file / folder, candidate module location '/src/foo', target file type 'DtsOnly'.", + "File '/src/foo.d.ts' does not exist.", + "Directory '/src/foo' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/foo/package.json' does not exist.", @@ -10,6 +13,9 @@ "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", + "Loading module as file / folder, candidate module location '/src/bar', target file type 'DtsOnly'.", + "File '/src/bar.d.ts' does not exist.", + "Directory '/src/bar' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", "File '/node_modules/bar/package.json' does not exist.", @@ -19,6 +25,9 @@ "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", + "Loading module as file / folder, candidate module location '/src/alpha', target file type 'DtsOnly'.", + "File '/src/alpha.d.ts' does not exist.", + "Directory '/src/alpha' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", @@ -27,6 +36,9 @@ "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", + "Loading module as file / folder, candidate module location '/src/alpha', target file type 'DtsOnly'.", + "File '/src/alpha.d.ts' does not exist.", + "Directory '/src/alpha' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-5.trace.json b/tests/baselines/reference/library-reference-5.trace.json index 0cac2a8fec6a1..42082be244b6e 100644 --- a/tests/baselines/reference/library-reference-5.trace.json +++ b/tests/baselines/reference/library-reference-5.trace.json @@ -1,6 +1,7 @@ [ "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/foo', target file type 'DtsOnly'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", @@ -11,6 +12,7 @@ "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/bar', target file type 'DtsOnly'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", @@ -21,6 +23,7 @@ "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/alpha', target file type 'DtsOnly'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", @@ -30,6 +33,7 @@ "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/alpha', target file type 'DtsOnly'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", diff --git a/tests/baselines/reference/library-reference-6.trace.json b/tests/baselines/reference/library-reference-6.trace.json index 3c682db6af7dd..d67427e64f64f 100644 --- a/tests/baselines/reference/library-reference-6.trace.json +++ b/tests/baselines/reference/library-reference-6.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'alpha', containing file '/src/foo.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/alpha', target file type 'DtsOnly'.", + "File '/node_modules/@types/alpha.d.ts' does not exist.", "File '/node_modules/@types/alpha/package.json' does not exist.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/alpha/index.d.ts', result '/node_modules/@types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/alpha', target file type 'DtsOnly'.", + "File '/node_modules/@types/alpha.d.ts' does not exist.", "File '/node_modules/@types/alpha/package.json' does not exist.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/alpha/index.d.ts', result '/node_modules/@types/alpha/index.d.ts'.", diff --git a/tests/baselines/reference/library-reference-8.trace.json b/tests/baselines/reference/library-reference-8.trace.json index 794df2daa7a82..c9a17bc730bc7 100644 --- a/tests/baselines/reference/library-reference-8.trace.json +++ b/tests/baselines/reference/library-reference-8.trace.json @@ -1,36 +1,48 @@ [ "======== Resolving type reference directive 'alpha', containing file '/test/foo.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", + "Loading module as file / folder, candidate module location '/test/types/alpha', target file type 'DtsOnly'.", + "File '/test/types/alpha.d.ts' does not exist.", "File '/test/types/alpha/package.json' does not exist.", "File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'beta', containing file '/test/foo.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", + "Loading module as file / folder, candidate module location '/test/types/beta', target file type 'DtsOnly'.", + "File '/test/types/beta.d.ts' does not exist.", "File '/test/types/beta/package.json' does not exist.", "File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.", "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'beta', containing file '/test/types/alpha/index.d.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", + "Loading module as file / folder, candidate module location '/test/types/beta', target file type 'DtsOnly'.", + "File '/test/types/beta.d.ts' does not exist.", "File '/test/types/beta/package.json' does not exist.", "File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.", "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/test/types/beta/index.d.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", + "Loading module as file / folder, candidate module location '/test/types/alpha', target file type 'DtsOnly'.", + "File '/test/types/alpha.d.ts' does not exist.", "File '/test/types/alpha/package.json' does not exist.", "File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", + "Loading module as file / folder, candidate module location '/test/types/alpha', target file type 'DtsOnly'.", + "File '/test/types/alpha.d.ts' does not exist.", "File '/test/types/alpha/package.json' does not exist.", "File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'beta', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", + "Loading module as file / folder, candidate module location '/test/types/beta', target file type 'DtsOnly'.", + "File '/test/types/beta.d.ts' does not exist.", "File '/test/types/beta/package.json' does not exist.", "File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.", diff --git a/tests/baselines/reference/library-reference-scoped-packages.trace.json b/tests/baselines/reference/library-reference-scoped-packages.trace.json index cfc8819820182..b04efee1f3fcf 100644 --- a/tests/baselines/reference/library-reference-scoped-packages.trace.json +++ b/tests/baselines/reference/library-reference-scoped-packages.trace.json @@ -1,6 +1,7 @@ [ "======== Resolving type reference directive '@beep/boop', containing file '/a.ts', root directory 'types'. ========", "Resolving with primary search path 'types'.", + "Loading module as file / folder, candidate module location 'types/@beep/boop', target file type 'DtsOnly'.", "Directory 'types/@beep' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/'.", "Scoped package detected, looking in 'beep__boop'", diff --git a/tests/baselines/reference/typeReferenceDirectives1.trace.json b/tests/baselines/reference/typeReferenceDirectives1.trace.json index 64994ab00b573..1feb49afc076d 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives1.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives10.trace.json b/tests/baselines/reference/typeReferenceDirectives10.trace.json index a91414a8ce189..c9fc8bb38e7b2 100644 --- a/tests/baselines/reference/typeReferenceDirectives10.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives10.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", @@ -14,6 +16,8 @@ "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives11.trace.json b/tests/baselines/reference/typeReferenceDirectives11.trace.json index 572648804aeb1..0a24176100fc9 100644 --- a/tests/baselines/reference/typeReferenceDirectives11.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives11.trace.json @@ -6,6 +6,8 @@ "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives12.trace.json b/tests/baselines/reference/typeReferenceDirectives12.trace.json index 12f8d938c1d64..a30d3cb7b16da 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives12.trace.json @@ -11,6 +11,8 @@ "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", @@ -20,6 +22,8 @@ "======== Module name './main' was successfully resolved to '/main.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives13.trace.json b/tests/baselines/reference/typeReferenceDirectives13.trace.json index a91414a8ce189..c9fc8bb38e7b2 100644 --- a/tests/baselines/reference/typeReferenceDirectives13.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives13.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", @@ -14,6 +16,8 @@ "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives2.trace.json b/tests/baselines/reference/typeReferenceDirectives2.trace.json index 47ae2761584fe..1141ea3ae3689 100644 --- a/tests/baselines/reference/typeReferenceDirectives2.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives2.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives3.trace.json b/tests/baselines/reference/typeReferenceDirectives3.trace.json index 64994ab00b573..1feb49afc076d 100644 --- a/tests/baselines/reference/typeReferenceDirectives3.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives3.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives4.trace.json b/tests/baselines/reference/typeReferenceDirectives4.trace.json index 64994ab00b573..1feb49afc076d 100644 --- a/tests/baselines/reference/typeReferenceDirectives4.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives4.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives5.trace.json b/tests/baselines/reference/typeReferenceDirectives5.trace.json index a91414a8ce189..c9fc8bb38e7b2 100644 --- a/tests/baselines/reference/typeReferenceDirectives5.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives5.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", @@ -14,6 +16,8 @@ "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives6.trace.json b/tests/baselines/reference/typeReferenceDirectives6.trace.json index 64994ab00b573..1feb49afc076d 100644 --- a/tests/baselines/reference/typeReferenceDirectives6.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives6.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives7.trace.json b/tests/baselines/reference/typeReferenceDirectives7.trace.json index 64994ab00b573..1feb49afc076d 100644 --- a/tests/baselines/reference/typeReferenceDirectives7.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives7.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives8.trace.json b/tests/baselines/reference/typeReferenceDirectives8.trace.json index 572648804aeb1..0a24176100fc9 100644 --- a/tests/baselines/reference/typeReferenceDirectives8.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives8.trace.json @@ -6,6 +6,8 @@ "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeReferenceDirectives9.trace.json b/tests/baselines/reference/typeReferenceDirectives9.trace.json index 12f8d938c1d64..a30d3cb7b16da 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives9.trace.json @@ -11,6 +11,8 @@ "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", @@ -20,6 +22,8 @@ "======== Module name './main' was successfully resolved to '/main.ts'. ========", "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.", + "File '/types/lib.d.ts' does not exist.", "File '/types/lib/package.json' does not exist.", "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", diff --git a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json index fdcbcdb7ab1d0..dcd5aed31ee16 100644 --- a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json +++ b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json @@ -58,18 +58,27 @@ "======== Module name 'abc' was not resolved. ========", "======== Resolving type reference directive 'grumpy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========", "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'.", + "Loading module as file / folder, candidate module location '/foo/node_modules/@types/grumpy', target file type 'DtsOnly'.", + "File '/foo/node_modules/@types/grumpy.d.ts' does not exist.", "File '/foo/node_modules/@types/grumpy/package.json' does not exist.", "File '/foo/node_modules/@types/grumpy/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/foo/node_modules/@types/grumpy/index.d.ts', result '/foo/node_modules/@types/grumpy/index.d.ts'.", "======== Type reference directive 'grumpy' was successfully resolved to '/foo/node_modules/@types/grumpy/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'sneezy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========", "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'.", + "Loading module as file / folder, candidate module location '/foo/node_modules/@types/sneezy', target file type 'DtsOnly'.", + "File '/foo/node_modules/@types/sneezy.d.ts' does not exist.", "File '/foo/node_modules/@types/sneezy/package.json' does not exist.", "File '/foo/node_modules/@types/sneezy/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/foo/node_modules/@types/sneezy/index.d.ts', result '/foo/node_modules/@types/sneezy/index.d.ts'.", "======== Type reference directive 'sneezy' was successfully resolved to '/foo/node_modules/@types/sneezy/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'dopey', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========", "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'.", + "Loading module as file / folder, candidate module location '/foo/node_modules/@types/dopey', target file type 'DtsOnly'.", + "File '/foo/node_modules/@types/dopey.d.ts' does not exist.", + "Directory '/foo/node_modules/@types/dopey' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/node_modules/@types/dopey', target file type 'DtsOnly'.", + "File '/node_modules/@types/dopey.d.ts' does not exist.", "File '/node_modules/@types/dopey/package.json' does not exist.", "File '/node_modules/@types/dopey/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/dopey/index.d.ts', result '/node_modules/@types/dopey/index.d.ts'.", diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json index a15e20239c65a..521aae6ea7258 100644 --- a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json @@ -14,6 +14,8 @@ "======== Module name 'xyz' was not resolved. ========", "======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/foo', target file type 'DtsOnly'.", + "File '/node_modules/@types/foo.d.ts' does not exist.", "File '/node_modules/@types/foo/package.json' does not exist.", "File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'.", diff --git a/tests/baselines/reference/typingsLookup1.trace.json b/tests/baselines/reference/typingsLookup1.trace.json index 9efcb84d49022..37de6235391eb 100644 --- a/tests/baselines/reference/typingsLookup1.trace.json +++ b/tests/baselines/reference/typingsLookup1.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "File '/node_modules/@types/jquery/package.json' does not exist.", "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "File '/node_modules/@types/jquery/package.json' does not exist.", "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", diff --git a/tests/baselines/reference/typingsLookup3.trace.json b/tests/baselines/reference/typingsLookup3.trace.json index 9efcb84d49022..37de6235391eb 100644 --- a/tests/baselines/reference/typingsLookup3.trace.json +++ b/tests/baselines/reference/typingsLookup3.trace.json @@ -1,12 +1,16 @@ [ "======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "File '/node_modules/@types/jquery/package.json' does not exist.", "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "File '/node_modules/@types/jquery/package.json' does not exist.", "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index 3ce97d9d8c983..764eb499ff781 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -65,6 +65,8 @@ "======== Module name 'mquery' was successfully resolved to '/node_modules/@types/mquery/mquery/index.tsx'. ========", "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", @@ -73,6 +75,8 @@ "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/kquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/kquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", @@ -85,6 +89,8 @@ "======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/lquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", @@ -95,6 +101,8 @@ "======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: true. ========", "======== Resolving type reference directive 'mquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/mquery', target file type 'DtsOnly'.", + "File '/node_modules/@types/mquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/mquery/package.json'.", "'package.json' does not have a 'typesVersions' field.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", diff --git a/tests/baselines/reference/typingsLookupAmd.trace.json b/tests/baselines/reference/typingsLookupAmd.trace.json index f18f63e7597b8..4a95ce356f773 100644 --- a/tests/baselines/reference/typingsLookupAmd.trace.json +++ b/tests/baselines/reference/typingsLookupAmd.trace.json @@ -41,6 +41,8 @@ "======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========", "======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "Loading module as file / folder, candidate module location '/node_modules/@types/a', target file type 'DtsOnly'.", + "File '/node_modules/@types/a.d.ts' does not exist.", "File '/node_modules/@types/a/package.json' does not exist.", "File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/a/index.d.ts', result '/node_modules/@types/a/index.d.ts'.", From 97b7cbc704aefe6054be6672163ac2b20a68ee61 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 17:14:40 -0700 Subject: [PATCH 6/9] Test to show even when typeRoots are specified, resolution falls back to node_modules in nearest directory --- ...eReferenceDirectiveWithFailedFromTypeRoot.js | 17 +++++++++++++++++ ...renceDirectiveWithFailedFromTypeRoot.symbols | 8 ++++++++ ...ceDirectiveWithFailedFromTypeRoot.trace.json | 16 ++++++++++++++++ ...ferenceDirectiveWithFailedFromTypeRoot.types | 8 ++++++++ ...eReferenceDirectiveWithFailedFromTypeRoot.ts | 17 +++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types create mode 100644 tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js new file mode 100644 index 0000000000000..31a14380856e6 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts] //// + +//// [dummy.d.ts] +declare const a2: number; + +//// [phaser.d.ts] +declare const a: number; + +//// [package.json] +{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + +//// [a.ts] +a; + + +//// [a.js] +a; diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols new file mode 100644 index 0000000000000..f29a1bafe2741 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols @@ -0,0 +1,8 @@ +=== /a.ts === +a; +>a : Symbol(a, Decl(phaser.d.ts, 0, 13)) + +=== /node_modules/phaser/types/phaser.d.ts === +declare const a: number; +>a : Symbol(a, Decl(phaser.d.ts, 0, 13)) + diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json new file mode 100644 index 0000000000000..2e33c9e18ed1f --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json @@ -0,0 +1,16 @@ +[ + "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========", + "Resolving with primary search path '/typings'.", + "Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.", + "File '/typings/phaser.d.ts' does not exist.", + "Directory '/typings/phaser' does not exist, skipping all lookups in it.", + "Looking up in 'node_modules' folder, initial location '/'.", + "Found 'package.json' at '/node_modules/phaser/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "File '/node_modules/phaser.d.ts' does not exist.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types/phaser.d.ts' that references '/node_modules/phaser/types/phaser.d.ts'.", + "File '/node_modules/phaser/types/phaser.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/phaser/types/phaser.d.ts', result '/node_modules/phaser/types/phaser.d.ts'.", + "======== Type reference directive 'phaser' was successfully resolved to '/node_modules/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3', primary: false. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types new file mode 100644 index 0000000000000..20416fc921d6d --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types @@ -0,0 +1,8 @@ +=== /a.ts === +a; +>a : number + +=== /node_modules/phaser/types/phaser.d.ts === +declare const a: number; +>a : number + diff --git a/tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts b/tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts new file mode 100644 index 0000000000000..6669499cb2c52 --- /dev/null +++ b/tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts @@ -0,0 +1,17 @@ +// @noImplicitReferences: true +// @typeRoots: /typings +// @types: phaser +// @traceResolution: true +// @currentDirectory: / + +// @Filename: /typings/dummy.d.ts +declare const a2: number; + +// @Filename: /node_modules/phaser/types/phaser.d.ts +declare const a: number; + +// @Filename: /node_modules/phaser/package.json +{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + +// @Filename: /a.ts +a; From e64e70f6a7b9df765111463ffe22fd29af78ce9b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 17 Jul 2020 17:19:05 -0700 Subject: [PATCH 7/9] Auto type reference directive shouldnt lookup in node_modules Fixes #37708 Bug 1 part of the issue --- src/compiler/diagnosticMessages.json | 4 ++ src/compiler/moduleNameResolver.ts | 41 ++++++------ src/compiler/resolutionCache.ts | 53 +++++++-------- src/compiler/types.ts | 1 - src/server/project.ts | 4 -- src/services/types.ts | 1 + .../unittests/tscWatch/programUpdates.ts | 54 ++++++++------- .../tsserver/cachingFileSystemInformation.ts | 2 +- .../unittests/tsserver/resolutionCache.ts | 52 +++++++++------ .../reference/api/tsserverlibrary.d.ts | 3 +- tests/baselines/reference/api/typescript.d.ts | 2 +- ...-from-config-file-path-if-config-exists.js | 4 +- ...exists-but-does-not-specifies-typeRoots.js | 65 +++++++++++++++++++ ...DirectiveWithFailedFromTypeRoot.errors.txt | 19 ++++++ ...nceDirectiveWithFailedFromTypeRoot.symbols | 8 +-- ...DirectiveWithFailedFromTypeRoot.trace.json | 11 +--- ...renceDirectiveWithFailedFromTypeRoot.types | 6 +- 17 files changed, 207 insertions(+), 123 deletions(-) create mode 100644 tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js create mode 100644 tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d0d66f0f959b8..67f3a74c99f1b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4473,6 +4473,10 @@ "category": "Message", "code": 6235 }, + "Resolving type reference directive for program with typeRoots, skipping lookup in 'node_modules' folder.": { + "category": "Message", + "code": 6236 + }, "Projects to reference": { "category": "Message", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 6c200c7fe0223..e69f064e15945 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -250,7 +250,7 @@ namespace ts { } if (currentDirectory !== undefined) { - return getDefaultTypeRoots(currentDirectory, host); + return getDefaultTypeRoots(currentDirectory); } } @@ -258,19 +258,11 @@ namespace ts { * Returns the path to every node_modules/@types directory from some ancestor directory. * Returns undefined if there are none. */ - function getDefaultTypeRoots(currentDirectory: string, host: { directoryExists?: (directoryName: string) => boolean }): string[] | undefined { - if (!host.directoryExists) { - return [combinePaths(currentDirectory, nodeModulesAtTypes)]; - // And if it doesn't exist, tough. - } - + function getDefaultTypeRoots(currentDirectory: string): string[] | undefined { let typeRoots: string[] | undefined; forEachAncestorDirectory(normalizePath(currentDirectory), directory => { const atTypes = combinePaths(directory, nodeModulesAtTypes); - if (host.directoryExists!(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - return undefined; + (typeRoots || (typeRoots = [])).push(atTypes); }); return typeRoots; } @@ -363,20 +355,25 @@ namespace ts { function secondaryLookup(): PathAndPackageId | undefined { const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile); - if (initialLocationForSecondaryLookup !== undefined) { - // check secondary locations - if (traceEnabled) { - trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } + // Do not resolve auto types from secondary location let result: Resolved | undefined; - if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) { - const searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + if (!options.typeRoots || !endsWith(containingFile!, inferredTypesContainingFile)) { + // check secondary locations + if (traceEnabled) { + trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) { + const searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); + result = searchResult && searchResult.value; + } + else { + const { path: candidate } = normalizePathAndParts(combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); + } } - else { - const { path: candidate } = normalizePathAndParts(combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)); - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); + else if (traceEnabled) { + trace(host, Diagnostics.Resolving_type_reference_directive_for_program_with_typeRoots_skipping_lookup_in_node_modules_folder); } const resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 56ea6a03e8047..41b355ff21c0c 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -869,26 +869,28 @@ namespace ts { function createTypeRootsWatch(typeRootPath: Path, typeRoot: string): FileWatcher { // Create new watch and recursive info - return resolutionHost.watchTypeRootsDirectory(typeRoot, fileOrDirectory => { - const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); - if (cachedDirectoryStructureHost) { - // Since the file existence changed, update the sourceFiles cache - cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); - } - - // For now just recompile - // We could potentially store more data here about whether it was/would be really be used or not - // and with that determine to trigger compilation but for now this is enough - hasChangedAutomaticTypeDirectiveNames = true; - resolutionHost.onChangedAutomaticTypeDirectiveNames(); + return canWatchTypeRootPath(typeRootPath) ? + resolutionHost.watchTypeRootsDirectory(typeRoot, fileOrDirectory => { + const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); + if (cachedDirectoryStructureHost) { + // Since the file existence changed, update the sourceFiles cache + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } - // Since directory watchers invoked are flaky, the failed lookup location events might not be triggered - // So handle to failed lookup locations here as well to ensure we are invalidating resolutions - const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath); - if (dirPath) { - scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - } - }, WatchDirectoryFlags.Recursive); + // For now just recompile + // We could potentially store more data here about whether it was/would be really be used or not + // and with that determine to trigger compilation but for now this is enough + hasChangedAutomaticTypeDirectiveNames = true; + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + + // Since directory watchers invoked are flaky, the failed lookup location events might not be triggered + // So handle to failed lookup locations here as well to ensure we are invalidating resolutions + const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath); + if (dirPath) { + scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); + } + }, WatchDirectoryFlags.Recursive) : + noopFileWatcher; } /** @@ -906,7 +908,7 @@ namespace ts { // we need to assume the directories exist to ensure that we can get all the type root directories that get included // But filter directories that are at root level to say directory doesnt exist, so that we arent watching them - const typeRoots = getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory }); + const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory }); if (typeRoots) { mutateMap( typeRootsWatches, @@ -922,12 +924,11 @@ namespace ts { } } - /** - * Use this function to return if directory exists to get type roots to watch - * If we return directory exists then only the paths will be added to type roots - * Hence return true for all directories except root directories which are filtered from watching - */ - function directoryExistsForTypeRootWatch(nodeTypesDirectory: string) { + function canWatchTypeRootPath(nodeTypesDirectory: string) { + // If type roots is specified, watch that path + if (resolutionHost.getCompilationSettings().typeRoots) return true; + + // Otherwise can watch directory only if we can watch the parent directory of node_modules/@types const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory)); const dirPath = resolutionHost.toPath(dir); return dirPath === rootPath || canWatchDirectory(dirPath); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0db378efd7b36..304c1c2a5f8b6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7748,7 +7748,6 @@ namespace ts { } export interface GetEffectiveTypeRootsHost { - directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } diff --git a/src/server/project.ts b/src/server/project.ts index 895ca04b4fc27..b113ec73228c0 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -2278,10 +2278,6 @@ namespace ts.server { return !!this.externalProjectRefCount; } - getEffectiveTypeRoots() { - return getEffectiveTypeRoots(this.getCompilationSettings(), this.directoryStructureHost) || []; - } - /*@internal*/ updateErrorOnNoInputFiles(fileNameResult: ExpandResult) { updateErrorForNoInputFiles(fileNameResult, this.getConfigFilePath(), this.configFileSpecs!, this.projectErrors!, this.canConfigFileJsonReportNoInputFiles); diff --git a/src/services/types.ts b/src/services/types.ts index 9eee73f99d4d8..a80893757c43b 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -250,6 +250,7 @@ namespace ts { readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; + directoryExists?(directoryName: string): boolean; /* * LS host can optionally implement these methods to support automatic updating when new type libraries are installed diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index 3faa145fe2cc6..66d22175132b7 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -812,29 +812,37 @@ declare const eval: any` ] }); - verifyTscWatch({ - scenario, - subScenario: "types should load from config file path if config exists", - commandLineArgs: ["-w", "-p", configFilePath], - sys: () => { - const f1 = { - path: "/a/b/app.ts", - content: "let x = 1" - }; - const config = { - path: configFilePath, - content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: [] } }) - }; - const node = { - path: "/a/b/node_modules/@types/node/index.d.ts", - content: "declare var process: any" - }; - const cwd = { - path: "/a/c" - }; - return createWatchedSystem([f1, config, node, cwd, libFile], { currentDirectory: cwd.path }); - }, - changes: emptyArray + describe("types from config file", () => { + function verifyTypesLoad(includeTypeRoots: boolean) { + verifyTscWatch({ + scenario, + subScenario: includeTypeRoots ? + "types should not load from config file path if config exists but does not specifies typeRoots" : + "types should load from config file path if config exists", + commandLineArgs: ["-w", "-p", configFilePath], + sys: () => { + const f1 = { + path: "/a/b/app.ts", + content: "let x = 1" + }; + const config = { + path: configFilePath, + content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: includeTypeRoots ? [] : undefined } }) + }; + const node = { + path: "/a/b/node_modules/@types/node/index.d.ts", + content: "declare var process: any" + }; + const cwd = { + path: "/a/c" + }; + return createWatchedSystem([f1, config, node, cwd, libFile], { currentDirectory: cwd.path }); + }, + changes: emptyArray + }); + } + verifyTypesLoad(/*includeTypeRoots*/ false); + verifyTypesLoad(/*includeTypeRoots*/ true); }); verifyTscWatch({ diff --git a/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts b/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts index e554ee4219cef..9d40ab6344e8d 100644 --- a/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts +++ b/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts @@ -391,7 +391,7 @@ namespace ts.projectSystem { const { configFileName } = projectService.openClientFile(file1.path); assert.equal(configFileName, tsconfigFile.path as server.NormalizedPath, `should find config`); checkNumberOfConfiguredProjects(projectService, 1); - const watchingRecursiveDirectories = [`${canonicalFrontendDir}/src`, `${canonicalFrontendDir}/types`, `${canonicalFrontendDir}/node_modules`].concat(getNodeModuleDirectories(getDirectoryPath(canonicalFrontendDir))); + const watchingRecursiveDirectories = [`${canonicalFrontendDir}/src`, `${canonicalFrontendDir}/types`, `${canonicalFrontendDir}/node_modules`]; const project = projectService.configuredProjects.get(canonicalConfigPath)!; verifyProjectAndWatchedDirectories(); diff --git a/src/testRunner/unittests/tsserver/resolutionCache.ts b/src/testRunner/unittests/tsserver/resolutionCache.ts index 7a88d42da050e..1e4dda4a3d65e 100644 --- a/src/testRunner/unittests/tsserver/resolutionCache.ts +++ b/src/testRunner/unittests/tsserver/resolutionCache.ts @@ -418,27 +418,37 @@ namespace ts.projectSystem { projectService.checkNumberOfProjects({ configuredProjects: 1 }); }); - it("types should load from config file path if config exists", () => { - const f1 = { - path: "/a/b/app.ts", - content: "let x = 1" - }; - const config = { - path: "/a/b/tsconfig.json", - content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: [] } }) - }; - const node = { - path: "/a/b/node_modules/@types/node/index.d.ts", - content: "declare var process: any" - }; - const cwd = { - path: "/a/c" - }; - const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path }); - const projectService = createProjectService(host); - projectService.openClientFile(f1.path); - projectService.checkNumberOfProjects({ configuredProjects: 1 }); - checkProjectActualFiles(configuredProjectAt(projectService, 0), [f1.path, node.path, config.path]); + describe("types from config file", () => { + function verifyTypesLoad(includeTypeRoots: boolean) { + const f1 = { + path: "/a/b/app.ts", + content: "let x = 1" + }; + const config = { + path: "/a/b/tsconfig.json", + content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: includeTypeRoots ? [] : undefined } }) + }; + const node = { + path: "/a/b/node_modules/@types/node/index.d.ts", + content: "declare var process: any" + }; + const cwd = { + path: "/a/c" + }; + const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path }); + const projectService = createProjectService(host); + projectService.openClientFile(f1.path); + projectService.checkNumberOfProjects({ configuredProjects: 1 }); + checkProjectActualFiles(configuredProjectAt(projectService, 0), [f1.path, config.path, ...(includeTypeRoots ? [] : [node.path])]); + } + + it("types should load from config file path if config exists", () => { + verifyTypesLoad(/*includeTypeRoots*/ false); + }); + + it("types should not load from config file path if config exists but does not specifies typeRoots", () => { + verifyTypesLoad(/*includeTypeRoots*/ true); + }); }); }); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 7989218091bee..c2a7904f0dec6 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3722,7 +3722,6 @@ declare namespace ts { noEmitHelpers?: boolean; } export interface GetEffectiveTypeRootsHost { - directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } export interface TextSpan { @@ -5334,6 +5333,7 @@ declare namespace ts { readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; + directoryExists?(directoryName: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; @@ -9304,7 +9304,6 @@ declare namespace ts.server { setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; close(): void; - getEffectiveTypeRoots(): string[]; } /** * Project whose configuration is handled externally, such as in a '.csproj'. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 76296ad0927b8..08ccbd3ec4bca 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3722,7 +3722,6 @@ declare namespace ts { noEmitHelpers?: boolean; } export interface GetEffectiveTypeRootsHost { - directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } export interface TextSpan { @@ -5334,6 +5333,7 @@ declare namespace ts { readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; + directoryExists?(directoryName: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; diff --git a/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js b/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js index 4b8bd538da9b5..2733d64deea78 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js +++ b/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js @@ -3,7 +3,7 @@ Input:: let x = 1 //// [/a/b/tsconfig.json] -{"compilerOptions":{"types":["node"],"typeRoots":[]}} +{"compilerOptions":{"types":["node"]}} //// [/a/b/node_modules/@types/node/index.d.ts] declare var process: any @@ -33,7 +33,7 @@ Output:: Program root files: ["/a/b/app.ts"] -Program options: {"types":["node"],"typeRoots":[],"watch":true,"project":"/a/b/tsconfig.json","configFilePath":"/a/b/tsconfig.json"} +Program options: {"types":["node"],"watch":true,"project":"/a/b/tsconfig.json","configFilePath":"/a/b/tsconfig.json"} Program files:: /a/lib/lib.d.ts /a/b/app.ts diff --git a/tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js b/tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js new file mode 100644 index 0000000000000..6bee6a1ff5fe6 --- /dev/null +++ b/tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js @@ -0,0 +1,65 @@ +Input:: +//// [/a/b/app.ts] +let x = 1 + +//// [/a/b/tsconfig.json] +{"compilerOptions":{"types":["node"],"typeRoots":[]}} + +//// [/a/b/node_modules/@types/node/index.d.ts] +declare var process: any + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js -w -p /a/b/tsconfig.json +Output:: +>> Screen clear +[12:00:25 AM] Starting compilation in watch mode... + + +error TS2688: Cannot find type definition file for 'node'. + + +[12:00:28 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/a/b/app.ts"] +Program options: {"types":["node"],"typeRoots":[],"watch":true,"project":"/a/b/tsconfig.json","configFilePath":"/a/b/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/a/b/app.ts + +No cached semantic diagnostics in the builder:: + +WatchedFiles:: +/a/b/tsconfig.json: + {"fileName":"/a/b/tsconfig.json","pollingInterval":250} +/a/b/app.ts: + {"fileName":"/a/b/app.ts","pollingInterval":250} +/a/lib/lib.d.ts: + {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/a/b: + {"directoryName":"/a/b","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/a/b/app.js] +var x = 1; + + diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt new file mode 100644 index 0000000000000..5a5432d9e3ef7 --- /dev/null +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt @@ -0,0 +1,19 @@ +error TS2688: Cannot find type definition file for 'phaser'. +/a.ts(1,1): error TS2304: Cannot find name 'a'. + + +!!! error TS2688: Cannot find type definition file for 'phaser'. +==== /a.ts (1 errors) ==== + a; + ~ +!!! error TS2304: Cannot find name 'a'. + +==== /typings/dummy.d.ts (0 errors) ==== + declare const a2: number; + +==== /node_modules/phaser/types/phaser.d.ts (0 errors) ==== + declare const a: number; + +==== /node_modules/phaser/package.json (0 errors) ==== + { "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols index f29a1bafe2741..d567da2a8cdb6 100644 --- a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols @@ -1,8 +1,4 @@ === /a.ts === a; ->a : Symbol(a, Decl(phaser.d.ts, 0, 13)) - -=== /node_modules/phaser/types/phaser.d.ts === -declare const a: number; ->a : Symbol(a, Decl(phaser.d.ts, 0, 13)) - +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json index 2e33c9e18ed1f..a8ae73728809e 100644 --- a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json @@ -4,13 +4,6 @@ "Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.", "File '/typings/phaser.d.ts' does not exist.", "Directory '/typings/phaser' does not exist, skipping all lookups in it.", - "Looking up in 'node_modules' folder, initial location '/'.", - "Found 'package.json' at '/node_modules/phaser/package.json'.", - "'package.json' does not have a 'typesVersions' field.", - "File '/node_modules/phaser.d.ts' does not exist.", - "'package.json' does not have a 'typings' field.", - "'package.json' has 'types' field 'types/phaser.d.ts' that references '/node_modules/phaser/types/phaser.d.ts'.", - "File '/node_modules/phaser/types/phaser.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/node_modules/phaser/types/phaser.d.ts', result '/node_modules/phaser/types/phaser.d.ts'.", - "======== Type reference directive 'phaser' was successfully resolved to '/node_modules/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3', primary: false. ========" + "Resolving type reference directive for program with typeRoots, skipping lookup in 'node_modules' folder.", + "======== Type reference directive 'phaser' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types index 20416fc921d6d..2ec6ffcf1be41 100644 --- a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types +++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types @@ -1,8 +1,4 @@ === /a.ts === a; ->a : number - -=== /node_modules/phaser/types/phaser.d.ts === -declare const a: number; ->a : number +>a : any From 70fd04c0a69657419e02b083404b4cabe25ea2e2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 22 Jul 2020 15:53:25 -0700 Subject: [PATCH 8/9] Add test that shows types file does not act as ambient module declaration. --- ...olutionAsTypeReferenceDirective.errors.txt | 15 ++++++++++++++ ...oduleResolutionAsTypeReferenceDirective.js | 16 +++++++++++++++ ...ResolutionAsTypeReferenceDirective.symbols | 8 ++++++++ ...olutionAsTypeReferenceDirective.trace.json | 20 +++++++++++++++++++ ...leResolutionAsTypeReferenceDirective.types | 8 ++++++++ ...solutionAsTypeReferenceDirectiveAmbient.js | 18 +++++++++++++++++ ...ionAsTypeReferenceDirectiveAmbient.symbols | 12 +++++++++++ ...AsTypeReferenceDirectiveAmbient.trace.json | 20 +++++++++++++++++++ ...utionAsTypeReferenceDirectiveAmbient.types | 12 +++++++++++ ...oduleResolutionAsTypeReferenceDirective.ts | 15 ++++++++++++++ ...solutionAsTypeReferenceDirectiveAmbient.ts | 17 ++++++++++++++++ 11 files changed, 161 insertions(+) create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.errors.txt create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json create mode 100644 tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types create mode 100644 tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts create mode 100644 tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.errors.txt b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.errors.txt new file mode 100644 index 0000000000000..67b0084fcfd89 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.errors.txt @@ -0,0 +1,15 @@ +/a.ts(1,20): error TS2307: Cannot find module 'phaser' or its corresponding type declarations. + + +==== /a.ts (1 errors) ==== + import { a2 } from "phaser"; + ~~~~~~~~ +!!! error TS2307: Cannot find module 'phaser' or its corresponding type declarations. + +==== /typings/phaser/types/phaser.d.ts (0 errors) ==== + export const a2: number; + +==== /typings/phaser/package.json (0 errors) ==== + { "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js new file mode 100644 index 0000000000000..2ed5901c0f6d4 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts] //// + +//// [phaser.d.ts] +export const a2: number; + +//// [package.json] +{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + + +//// [a.ts] +import { a2 } from "phaser"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols new file mode 100644 index 0000000000000..412bc680e0c31 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols @@ -0,0 +1,8 @@ +=== /a.ts === +import { a2 } from "phaser"; +>a2 : Symbol(a2, Decl(a.ts, 0, 8)) + +=== /typings/phaser/types/phaser.d.ts === +export const a2: number; +>a2 : Symbol(a2, Decl(phaser.d.ts, 0, 12)) + diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json new file mode 100644 index 0000000000000..51c6df7e4bbb9 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json @@ -0,0 +1,20 @@ +[ + "======== Resolving module 'phaser' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'phaser' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Loading module 'phaser' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name 'phaser' was not resolved. ========", + "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========", + "Resolving with primary search path '/typings'.", + "Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.", + "File '/typings/phaser.d.ts' does not exist.", + "Found 'package.json' at '/typings/phaser/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types/phaser.d.ts' that references '/typings/phaser/types/phaser.d.ts'.", + "File '/typings/phaser/types/phaser.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/typings/phaser/types/phaser.d.ts', result '/typings/phaser/types/phaser.d.ts'.", + "======== Type reference directive 'phaser' was successfully resolved to '/typings/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3', primary: true. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types new file mode 100644 index 0000000000000..6850ad3d8afef --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types @@ -0,0 +1,8 @@ +=== /a.ts === +import { a2 } from "phaser"; +>a2 : any + +=== /typings/phaser/types/phaser.d.ts === +export const a2: number; +>a2 : number + diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js new file mode 100644 index 0000000000000..1a23de3a2e708 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts] //// + +//// [phaser.d.ts] +declare module "phaser" { + export const a2: number; +} + +//// [package.json] +{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + + +//// [a.ts] +import { a2 } from "phaser"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols new file mode 100644 index 0000000000000..578a81a43c756 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols @@ -0,0 +1,12 @@ +=== /a.ts === +import { a2 } from "phaser"; +>a2 : Symbol(a2, Decl(a.ts, 0, 8)) + +=== /typings/phaser/types/phaser.d.ts === +declare module "phaser" { +>"phaser" : Symbol("phaser", Decl(phaser.d.ts, 0, 0)) + + export const a2: number; +>a2 : Symbol(a2, Decl(phaser.d.ts, 1, 16)) +} + diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json new file mode 100644 index 0000000000000..51c6df7e4bbb9 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json @@ -0,0 +1,20 @@ +[ + "======== Resolving module 'phaser' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'phaser' from 'node_modules' folder, target file type 'TypeScript'.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Loading module 'phaser' from 'node_modules' folder, target file type 'JavaScript'.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name 'phaser' was not resolved. ========", + "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========", + "Resolving with primary search path '/typings'.", + "Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.", + "File '/typings/phaser.d.ts' does not exist.", + "Found 'package.json' at '/typings/phaser/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types/phaser.d.ts' that references '/typings/phaser/types/phaser.d.ts'.", + "File '/typings/phaser/types/phaser.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/typings/phaser/types/phaser.d.ts', result '/typings/phaser/types/phaser.d.ts'.", + "======== Type reference directive 'phaser' was successfully resolved to '/typings/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3', primary: true. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types new file mode 100644 index 0000000000000..6bc892a4e4145 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types @@ -0,0 +1,12 @@ +=== /a.ts === +import { a2 } from "phaser"; +>a2 : number + +=== /typings/phaser/types/phaser.d.ts === +declare module "phaser" { +>"phaser" : typeof import("phaser") + + export const a2: number; +>a2 : number +} + diff --git a/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts new file mode 100644 index 0000000000000..79e6f75757aed --- /dev/null +++ b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts @@ -0,0 +1,15 @@ +// @noImplicitReferences: true +// @typeRoots: /typings +// @types: phaser +// @traceResolution: true +// @currentDirectory: / + +// @Filename: /typings/phaser/types/phaser.d.ts +export const a2: number; + +// @Filename: /typings/phaser/package.json +{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + + +// @Filename: /a.ts +import { a2 } from "phaser"; diff --git a/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts new file mode 100644 index 0000000000000..6002252f46615 --- /dev/null +++ b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts @@ -0,0 +1,17 @@ +// @noImplicitReferences: true +// @typeRoots: /typings +// @types: phaser +// @traceResolution: true +// @currentDirectory: / + +// @Filename: /typings/phaser/types/phaser.d.ts +declare module "phaser" { + export const a2: number; +} + +// @Filename: /typings/phaser/package.json +{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" } + + +// @Filename: /a.ts +import { a2 } from "phaser"; From 1978d367defb3ebff610118f12829f3c2ec92a8d Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 22 Jul 2020 15:58:59 -0700 Subject: [PATCH 9/9] TODOs for later --- src/compiler/moduleNameResolver.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e69f064e15945..1641fd812b562 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -941,6 +941,7 @@ namespace ts { if (traceEnabled) { trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } + // TODO:: resolve type ference directive const resolved = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved) return undefined; @@ -1470,7 +1471,8 @@ namespace ts { } if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. - return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state); + // TODO type referecnce like resolution + return resolveTypeReferenceDirective(moduleName, containingFile, containingDirectory, state); } } else {