Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dont lower case file name for type ref
  • Loading branch information
sheetalkamat committed May 13, 2024
commit 8d92aef02fcad8190acd3a9b4eafe99e80038f37
7 changes: 3 additions & 4 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,7 @@ export function createModuleResolutionLoader(
}

function getTypeReferenceResolutionName<T extends FileReference | string>(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<FileReference | string, SourceFile | undefined> = {
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 /// <reference types="./fileOne.d.ts"/>
   ~~~~~~~~~~~~~~

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


Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stops showing as this because of how this is processed. When the UpperCasePackage typings are already found and are primary then they are not processed again and hence the file reason for this is never added. Thats a separate issue and am looking into updating that code as well but its not related to this change.

it just stopped showing because before this the package name by auto type ref was "UpperCasePackage" while by type Ref was "uppercasepackage" which made two distinct entries and hence processed again.

../lib/@app/lib/index.d.ts
Entry point for implicit type library 'lib'

Expand Down Expand Up @@ -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)
Expand Down