From b407c7e9f9ee5d080d34891bbc99725feee3af40 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 13 May 2024 13:53:53 -0700 Subject: [PATCH 1/3] Tests --- .../tsc/forceConsistentCasingInFileNames.ts | 15 ++++ .../tsserver/typeReferenceDirectives.ts | 3 +- .../with-type-ref-from-file.js | 75 +++++++++++++++++ ...enceDirective-contains-UpperCasePackage.js | 80 ++++++++++++++++++- 4 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js diff --git a/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts b/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts index 4966d55db070a..3e5cc966d83b6 100644 --- a/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts +++ b/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts @@ -26,4 +26,19 @@ describe("unittests:: tsc:: forceConsistentCasingInFileNames::", () => { commandLineArgs: ["-p", "/home/src/projects/project/tsconfig.json", "--explainFiles"], fs: () => loadProjectFromFiles(getFsContentsForMultipleErrorsForceConsistentCasingInFileNames()), }); + + verifyTsc({ + scenario: "forceConsistentCasingInFileNames", + subScenario: "with type ref from file", + commandLineArgs: ["-p", "/src/project/src", "--explainFiles", "--traceResolution"], + fs: () => + loadProjectFromFiles({ + "/src/project/src/fileOne.d.ts": `declare class c { }`, + "/src/project/src/file2.d.ts": dedent` + /// + declare const y: c; + `, + "/src/project/src/tsconfig.json": "{ }", + }), + }); }); diff --git a/src/testRunner/unittests/tsserver/typeReferenceDirectives.ts b/src/testRunner/unittests/tsserver/typeReferenceDirectives.ts index f78772759bde4..167a707458b48 100644 --- a/src/testRunner/unittests/tsserver/typeReferenceDirectives.ts +++ b/src/testRunner/unittests/tsserver/typeReferenceDirectives.ts @@ -10,7 +10,7 @@ import { libFile, } from "../helpers/virtualFileSystemWithWatch.js"; -describe("unittests:: tsserver:: typeReferenceDirectives", () => { +describe("unittests:: tsserver:: typeReferenceDirectives::", () => { it("when typeReferenceDirective contains UpperCasePackage", () => { const libProjectLocation = `/user/username/projects/myproject/lib`; const typeLib: File = { @@ -52,6 +52,7 @@ declare class TestLib { compilerOptions: { module: "amd", typeRoots: ["../lib/@types", "../lib/@app"], + traceResolution: true, }, }), }; diff --git a/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js b/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js new file mode 100644 index 0000000000000..4fb6de464f71e --- /dev/null +++ b/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js @@ -0,0 +1,75 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/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; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/project/src/file2.d.ts] +/// +declare const y: c; + + +//// [/src/project/src/fileOne.d.ts] +declare class c { } + +//// [/src/project/src/tsconfig.json] +{ } + + + +Output:: +/lib/tsc -p /src/project/src --explainFiles --traceResolution +File '/src/project/src/package.json' does not exist. +File '/src/project/package.json' does not exist. +File '/src/package.json' does not exist. +File '/package.json' does not exist. +======== Resolving type reference directive './fileone.d.ts', containing file '/src/project/src/file2.d.ts', root directory '/src/project/src/node_modules/@types,/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/project/src/node_modules/@types, /src/project/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/project/src/node_modules/@types' does not exist, skipping all lookups in it. +Directory '/src/project/node_modules/@types' does not exist, skipping all lookups in it. +Directory '/src/node_modules/@types' does not exist, skipping all lookups in it. +Directory '/node_modules/@types' does not exist, skipping all lookups in it. +Looking up in 'node_modules' folder, initial location '/src/project/src'. +Loading module as file / folder, candidate module location '/src/project/src/fileone.d.ts', target file types: Declaration. +File name '/src/project/src/fileone.d.ts' has a '.d.ts' extension - stripping it. +File '/src/project/src/fileone.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/project/src/fileone.d.ts', result '/src/project/src/fileOne.d.ts'. +======== Type reference directive './fileone.d.ts' was successfully resolved to '/src/project/src/fileone.d.ts', primary: false. ======== +File '/src/project/src/package.json' does not exist according to earlier cached lookups. +File '/src/project/package.json' does not exist according to earlier cached lookups. +File '/src/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +File '/lib/package.json' does not exist. +File '/package.json' does not exist according to earlier cached lookups. +src/project/src/file2.d.ts:1:23 - error TS1261: Already included file name '/src/project/src/fileone.d.ts' differs from file name '/src/project/src/fileOne.d.ts' only in casing. + The file is in the program because: + Type library referenced via './fileOne.d.ts' from file '/src/project/src/file2.d.ts' + Matched by default include pattern '**/*' + +1 /// +   ~~~~~~~~~~~~~~ + +lib/lib.d.ts + Default library for target 'es5' +src/project/src/fileone.d.ts + Type library referenced via './fileOne.d.ts' from file 'src/project/src/file2.d.ts' + Matched by default include pattern '**/*' +src/project/src/file2.d.ts + Matched by default include pattern '**/*' + +Found 1 error in src/project/src/file2.d.ts:1 + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated + + diff --git a/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js b/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js index edd87db29bcca..677b45e600df5 100644 --- a/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js +++ b/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js @@ -37,7 +37,8 @@ class TestClass1 { "typeRoots": [ "../lib/@types", "../lib/@app" - ] + ], + "traceResolution": true } } @@ -87,16 +88,64 @@ Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/test/tsconfig "/user/username/projects/myproject/lib/@types", "/user/username/projects/myproject/lib/@app" ], + "traceResolution": true, "configFilePath": "/user/username/projects/myproject/test/tsconfig.json" } } Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/test 1 undefined Config: /user/username/projects/myproject/test/tsconfig.json WatchType: Wild card directory Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/test 1 undefined Config: /user/username/projects/myproject/test/tsconfig.json WatchType: Wild card directory Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/test/tsconfig.json +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/test/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist. +Info seq [hh:mm:ss:mss] ======== Resolving type reference directive 'UpperCasePackage', containing file '/user/username/projects/myproject/test/__inferred type names__.ts', root directory '/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'. ======== +Info seq [hh:mm:ss:mss] Resolving with primary search path '/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts', result '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'. +Info seq [hh:mm:ss:mss] ======== Type reference directive 'UpperCasePackage' was successfully resolved to '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts', primary: true. ======== Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib 1 undefined Project: /user/username/projects/myproject/test/tsconfig.json WatchType: Failed Lookup Locations Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib 1 undefined Project: /user/username/projects/myproject/test/tsconfig.json WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] ======== Resolving type reference directive 'lib', containing file '/user/username/projects/myproject/test/__inferred type names__.ts', root directory '/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'. ======== +Info seq [hh:mm:ss:mss] Resolving with primary search path '/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/lib.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/lib.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/lib/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/lib/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/user/username/projects/myproject/lib/@app/lib/index.d.ts', result '/user/username/projects/myproject/lib/@app/lib/index.d.ts'. +Info seq [hh:mm:ss:mss] ======== Type reference directive 'lib' was successfully resolved to '/user/username/projects/myproject/lib/@app/lib/index.d.ts', primary: true. ======== +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/lib/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib/@app/lib/index.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] ======== Resolving type reference directive 'uppercasepackage', containing file '/user/username/projects/myproject/lib/@app/lib/index.d.ts', root directory '/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'. ======== +Info seq [hh:mm:ss:mss] Resolving with primary search path '/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/uppercasepackage.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/uppercasepackage/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts', result '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'. +Info seq [hh:mm:ss:mss] ======== Type reference directive 'uppercasepackage' was successfully resolved to '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts', primary: true. ======== +Info seq [hh:mm:ss:mss] File '/a/lib/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/a/package.json' does not exist. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib/@types 1 undefined Project: /user/username/projects/myproject/test/tsconfig.json WatchType: Type roots Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib/@types 1 undefined Project: /user/username/projects/myproject/test/tsconfig.json WatchType: Type roots @@ -159,7 +208,8 @@ Info seq [hh:mm:ss:mss] event: "typeRoots": [ "", "" - ] + ], + "traceResolution": true }, "typeAcquisition": { "enable": false, @@ -292,6 +342,32 @@ ScriptInfos:: Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/test/tsconfig.json Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/test/tsconfig.json +Info seq [hh:mm:ss:mss] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/a/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/test/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/lib/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@app/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] Reusing resolution of type reference directive 'uppercasepackage' from '/user/username/projects/myproject/lib/@app/lib/index.d.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts'. Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/test/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/test/tsconfig.json' (Configured) Info seq [hh:mm:ss:mss] Files (4) From 8d92aef02fcad8190acd3a9b4eafe99e80038f37 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 13 May 2024 13:27:42 -0700 Subject: [PATCH 2/3] Dont lower case file name for type ref --- src/compiler/program.ts | 7 +++-- .../with-type-ref-from-file.js | 27 ++++++------------- ...enceDirective-contains-UpperCasePackage.js | 15 +++++------ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5093701605218..c20d978b5852d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1058,8 +1058,7 @@ export function createModuleResolutionLoader( } function getTypeReferenceResolutionName(entry: T) { - // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. - return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry; + return !isString(entry) ? entry.fileName : entry; } const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter = { @@ -1257,7 +1256,7 @@ export function getReferencedFileLocation(program: Program, ref: ReferencedFile) break; case FileIncludeKind.TypeReferenceDirective: ({ pos, end, resolutionMode } = file.typeReferenceDirectives[index]); - packageId = program.getResolvedTypeReferenceDirective(file, toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)?.resolvedTypeReferenceDirective?.packageId; + packageId = program.getResolvedTypeReferenceDirective(file, file.typeReferenceDirectives[index].fileName, resolutionMode || file.impliedNodeFormat)?.resolvedTypeReferenceDirective?.packageId; break; case FileIncludeKind.LibReferenceDirective: ({ pos, end } = file.libReferenceDirectives[index]); @@ -3990,7 +3989,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const ref = file.typeReferenceDirectives[index]; const resolvedTypeReferenceDirective = resolutions[index]; // store resolved type directive on the file - const fileName = toFileNameLowerCase(ref.fileName); + const fileName = ref.fileName; resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective); const mode = ref.resolutionMode || getDefaultResolutionModeForFile(file); processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: FileIncludeKind.TypeReferenceDirective, file: file.path, index }); diff --git a/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js b/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js index 4fb6de464f71e..7ea061cd3d89b 100644 --- a/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js +++ b/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-type-ref-from-file.js @@ -34,42 +34,31 @@ File '/src/project/src/package.json' does not exist. File '/src/project/package.json' does not exist. File '/src/package.json' does not exist. File '/package.json' does not exist. -======== Resolving type reference directive './fileone.d.ts', containing file '/src/project/src/file2.d.ts', root directory '/src/project/src/node_modules/@types,/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +======== Resolving type reference directive './fileOne.d.ts', containing file '/src/project/src/file2.d.ts', root directory '/src/project/src/node_modules/@types,/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== Resolving with primary search path '/src/project/src/node_modules/@types, /src/project/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. Directory '/src/project/src/node_modules/@types' does not exist, skipping all lookups in it. Directory '/src/project/node_modules/@types' does not exist, skipping all lookups in it. Directory '/src/node_modules/@types' does not exist, skipping all lookups in it. Directory '/node_modules/@types' does not exist, skipping all lookups in it. Looking up in 'node_modules' folder, initial location '/src/project/src'. -Loading module as file / folder, candidate module location '/src/project/src/fileone.d.ts', target file types: Declaration. -File name '/src/project/src/fileone.d.ts' has a '.d.ts' extension - stripping it. -File '/src/project/src/fileone.d.ts' exists - use it as a name resolution result. -Resolving real path for '/src/project/src/fileone.d.ts', result '/src/project/src/fileOne.d.ts'. -======== Type reference directive './fileone.d.ts' was successfully resolved to '/src/project/src/fileone.d.ts', primary: false. ======== +Loading module as file / folder, candidate module location '/src/project/src/fileOne.d.ts', target file types: Declaration. +File name '/src/project/src/fileOne.d.ts' has a '.d.ts' extension - stripping it. +File '/src/project/src/fileOne.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/project/src/fileOne.d.ts', result '/src/project/src/fileOne.d.ts'. +======== Type reference directive './fileOne.d.ts' was successfully resolved to '/src/project/src/fileOne.d.ts', primary: false. ======== File '/src/project/src/package.json' does not exist according to earlier cached lookups. File '/src/project/package.json' does not exist according to earlier cached lookups. File '/src/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -src/project/src/file2.d.ts:1:23 - error TS1261: Already included file name '/src/project/src/fileone.d.ts' differs from file name '/src/project/src/fileOne.d.ts' only in casing. - The file is in the program because: - Type library referenced via './fileOne.d.ts' from file '/src/project/src/file2.d.ts' - Matched by default include pattern '**/*' - -1 /// -   ~~~~~~~~~~~~~~ - lib/lib.d.ts Default library for target 'es5' -src/project/src/fileone.d.ts +src/project/src/fileOne.d.ts Type library referenced via './fileOne.d.ts' from file 'src/project/src/file2.d.ts' Matched by default include pattern '**/*' src/project/src/file2.d.ts Matched by default include pattern '**/*' - -Found 1 error in src/project/src/file2.d.ts:1 - -exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated +exitCode:: ExitStatus.Success diff --git a/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js b/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js index 677b45e600df5..b6cde6e156809 100644 --- a/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js +++ b/tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js @@ -136,13 +136,13 @@ Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist accor Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/lib/@app/lib/index.d.ts 500 undefined WatchType: Closed Script info -Info seq [hh:mm:ss:mss] ======== Resolving type reference directive 'uppercasepackage', containing file '/user/username/projects/myproject/lib/@app/lib/index.d.ts', root directory '/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'. ======== +Info seq [hh:mm:ss:mss] ======== Resolving type reference directive 'UpperCasePackage', containing file '/user/username/projects/myproject/lib/@app/lib/index.d.ts', root directory '/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'. ======== Info seq [hh:mm:ss:mss] Resolving with primary search path '/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'. -Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/uppercasepackage.d.ts' does not exist. -Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/uppercasepackage/package.json' does not exist according to earlier cached lookups. -Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts' exists - use it as a name resolution result. -Info seq [hh:mm:ss:mss] Resolving real path for '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts', result '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'. -Info seq [hh:mm:ss:mss] ======== Type reference directive 'uppercasepackage' was successfully resolved to '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts', primary: true. ======== +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage.d.ts' does not exist. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json' does not exist according to earlier cached lookups. +Info seq [hh:mm:ss:mss] File '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts' exists - use it as a name resolution result. +Info seq [hh:mm:ss:mss] Resolving real path for '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts', result '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'. +Info seq [hh:mm:ss:mss] ======== Type reference directive 'UpperCasePackage' was successfully resolved to '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts', primary: true. ======== Info seq [hh:mm:ss:mss] File '/a/lib/package.json' does not exist. Info seq [hh:mm:ss:mss] File '/a/package.json' does not exist. Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. @@ -166,7 +166,6 @@ Info seq [hh:mm:ss:mss] Files (4) Matched by default include pattern '**/*' ../lib/@types/UpperCasePackage/index.d.ts Entry point for implicit type library 'UpperCasePackage' - Type library referenced via 'UpperCasePackage' from file '../lib/@app/lib/index.d.ts' ../lib/@app/lib/index.d.ts Entry point for implicit type library 'lib' @@ -367,7 +366,7 @@ Info seq [hh:mm:ss:mss] File '/user/username/projects/package.json' does not ex Info seq [hh:mm:ss:mss] File '/user/username/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] File '/user/package.json' does not exist according to earlier cached lookups. Info seq [hh:mm:ss:mss] File '/package.json' does not exist according to earlier cached lookups. -Info seq [hh:mm:ss:mss] Reusing resolution of type reference directive 'uppercasepackage' from '/user/username/projects/myproject/lib/@app/lib/index.d.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/lib/@types/uppercasepackage/index.d.ts'. +Info seq [hh:mm:ss:mss] Reusing resolution of type reference directive 'UpperCasePackage' from '/user/username/projects/myproject/lib/@app/lib/index.d.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'. Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/test/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/test/tsconfig.json' (Configured) Info seq [hh:mm:ss:mss] Files (4) From 50d79acd4946efd9b54d0bba7fdb7bff60819f1e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 13 May 2024 14:21:39 -0700 Subject: [PATCH 3/3] Update conformance test --- .../baselines/reference/typingsLookup3.errors.txt | 15 +++++++++++++++ .../baselines/reference/typingsLookup3.trace.json | 12 ++++++++---- tests/baselines/reference/typingsLookup3.types | 2 ++ tests/cases/conformance/typings/typingsLookup3.ts | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/typingsLookup3.errors.txt diff --git a/tests/baselines/reference/typingsLookup3.errors.txt b/tests/baselines/reference/typingsLookup3.errors.txt new file mode 100644 index 0000000000000..5073cb549393c --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.errors.txt @@ -0,0 +1,15 @@ +/a.ts(1,23): error TS2688: Cannot find type definition file for 'JqUeRy'. + + +==== /tsconfig.json (0 errors) ==== + { "files": "a.ts" } + +==== /a.ts (1 errors) ==== + /// + ~~~~~~ +!!! error TS2688: Cannot find type definition file for 'JqUeRy'. + $.x; + +==== /node_modules/@types/jquery/index.d.ts (0 errors) ==== + declare var $: { x: any }; + \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup3.trace.json b/tests/baselines/reference/typingsLookup3.trace.json index 34f0b54b8debb..817ce49ceff11 100644 --- a/tests/baselines/reference/typingsLookup3.trace.json +++ b/tests/baselines/reference/typingsLookup3.trace.json @@ -1,6 +1,13 @@ [ "File '/package.json' does not exist.", - "======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========", + "======== Resolving type reference directive 'JqUeRy', containing file '/a.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'.", + "Looking up in 'node_modules' folder, initial location '/'.", + "Searching all ancestor node_modules directories for preferred extensions: Declaration.", + "File '/node_modules/JqUeRy.d.ts' does not exist.", + "File '/node_modules/@types/JqUeRy.d.ts' does not exist.", + "======== Type reference directive 'JqUeRy' was not resolved. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", "File '/node_modules/@types/jquery/package.json' does not exist.", "File '/node_modules/@types/jquery/index.d.ts' exists - use it as a name resolution result.", @@ -10,9 +17,6 @@ "File '/node_modules/@types/package.json' does not exist.", "File '/node_modules/package.json' does not exist.", "File '/package.json' does not exist according to earlier cached lookups.", - "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts'. ========", - "Resolution for type reference directive 'jquery' was found in cache from location '/'.", - "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", "File '/.ts/package.json' does not exist.", "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-es5' from '/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", diff --git a/tests/baselines/reference/typingsLookup3.types b/tests/baselines/reference/typingsLookup3.types index feb2bc5be0433..98bcced62d7e6 100644 --- a/tests/baselines/reference/typingsLookup3.types +++ b/tests/baselines/reference/typingsLookup3.types @@ -4,6 +4,7 @@ /// $.x; >$.x : any +> : ^^^ >$ : { x: any; } > : ^^^^^^^^^^^ >x : any @@ -14,4 +15,5 @@ declare var $: { x: any }; >$ : { x: any; } > : ^^^^^ ^^^ >x : any +> : ^^^ diff --git a/tests/cases/conformance/typings/typingsLookup3.ts b/tests/cases/conformance/typings/typingsLookup3.ts index a0bb15476b982..62ac683ba2a45 100644 --- a/tests/cases/conformance/typings/typingsLookup3.ts +++ b/tests/cases/conformance/typings/typingsLookup3.ts @@ -1,7 +1,7 @@ // @traceResolution: true // @noImplicitReferences: true // @currentDirectory: / -// This tests that `types` references are automatically lowercased. +// This tests that `types` references are not lowercased. // @filename: /tsconfig.json { "files": "a.ts" }