Skip to content

TS wrong calculate case sensitive repo as case insensitive filesystem #63100

@baymer

Description

@baymer

🔎 Search Terms

CaseInsensitive CaseSensitive

🕗 Version & Regression Information

  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

No response

💻 Code

// Your code here

🙁 Actual behavior

Repository on overlayfs with CaseSensitive filesystem and symlinlinked node_modules outside of repo to pnpm virtual-store with CaseInsensitive filesystem (mac os)
and any source ts-files with capital letter, like obtainRuntimeContextHandlerResults.ts
Then type checking is falling down with the error:

~/overlayfsrepo/frontend/packages/composer/src/utils/obtainRuntimeContextHandlerResults.ts
  0:0  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/src/utils/obtainRuntimeContextHandlerResults.ts` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/troubleshooting/typed-linting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

to fix that we use that pnpm-patch

diff --git a/lib/typescript.js b/lib/typescript.js
index 2643aa12aa6497ca0b90ecd99b202f37ea0e6330..34757f4fb1a2958bec5142c6e365c4214a2f36fb 100644
--- a/lib/typescript.js
+++ b/lib/typescript.js
@@ -8277,11 +8277,11 @@ var sys = (() => {
     const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
     const statSyncOptions = { throwIfNoEntry: false };
     const platform = _os.platform();
+    const getCurrentDirectory = memoize(() => process.cwd());
     const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
     const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
     const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
     const fsSupportsRecursiveFsWatch = process.platform === "win32" || isMacOs;
-    const getCurrentDirectory = memoize(() => process.cwd());
     const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
       pollingWatchFileWorker: fsWatchFileWorker,
       getModifiedTime: getModifiedTime3,
@@ -8484,7 +8484,7 @@ var sys = (() => {
       if (platform === "win32" || platform === "win64") {
         return false;
       }
-      return !fileExists(swapCase(__filename));
+      return !fileExists(swapCase(getCurrentDirectory()));
     }
     function swapCase(s) {
       return s.replace(/\w/g, (ch) => {

it would be better to fix it in the upstream

🙂 Expected behavior

the system calcs the source dir, not the node_modules or pnpm-virtual-store dir

Additional information about the issue

the fix is https://github.com/microsoft/TypeScript/pull/63099/changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions