Fix self reference package with casing

This commit is contained in:
Sheetal Nandi
2022-08-31 12:52:50 -07:00
parent fc35e0a032
commit 9076f4d57d
2 changed files with 6 additions and 15 deletions
+2 -2
View File
@@ -2249,7 +2249,7 @@ namespace ts {
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
&& finalPath.indexOf("/node_modules/") === -1
&& (state.compilerOptions.configFile ? startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)
&& (state.compilerOptions.configFile ? containsPath(scope.packageDirectory, toAbsolutePath(state.compilerOptions.configFile.fileName), !useCaseSensitiveFileNames()) : true)
) {
// So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
@@ -2310,7 +2310,7 @@ namespace ts {
for (const commonSourceDirGuess of commonSourceDirGuesses) {
const candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
for (const candidateDir of candidateDirectories) {
if (startsWith(finalPath, candidateDir)) {
if (containsPath(candidateDir, finalPath, !useCaseSensitiveFileNames())) {
// The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension
const pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
const possibleInputBase = combinePaths(commonSourceDirGuess, pathFragment);
@@ -35,28 +35,19 @@ Found 'package.json' at '/users/name/projects/web/package.json'.
======== Resolving module '@this/package' from '/Users/name/projects/web/index.ts'. ========
Module resolution kind is not specified, using 'NodeNext'.
File '/users/name/projects/web/package.json' exists according to earlier cached lookups.
File '/users/name/projects/web/index.ts' exist - use it as a name resolution result.
Resolving real path for '/users/name/projects/web/index.ts', result '/Users/name/projects/web/index.ts'.
======== Module name '@this/package' was successfully resolved to '/users/name/projects/web/index.ts'. ========
File '/Users/name/projects/web/index.ts' exist - use it as a name resolution result.
Resolving real path for '/Users/name/projects/web/index.ts', result '/Users/name/projects/web/index.ts'.
======== Module name '@this/package' was successfully resolved to '/Users/name/projects/web/index.ts'. ========
File '/a/lib/package.json' does not exist.
File '/a/package.json' does not exist.
File '/package.json' does not exist.
index.ts:1:21 - error TS1149: File name '/users/name/projects/web/index.ts' differs from already included file name '/Users/name/projects/web/index.ts' only in casing.
The file is in the program because:
Matched by default include pattern '**/*'
Imported via "@this/package" from file '/Users/name/projects/web/index.ts'
File is ECMAScript module because '/users/name/projects/web/package.json' has field "type" with value "module"
1 import * as me from "@this/package";
   ~~~~~~~~~~~~~~~
../../../../a/lib/lib.esnext.full.d.ts
Default library for target 'esnext'
index.ts
Matched by default include pattern '**/*'
Imported via "@this/package" from file 'index.ts'
File is ECMAScript module because 'package.json' has field "type" with value "module"
[12:00:36 AM] Found 1 error. Watching for file changes.
[12:00:36 AM] Found 0 errors. Watching for file changes.