-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Use fs.realpathSync.native when available #41292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4c44730
Test that forceConsistentCasingInFileNames does not apply to Windows …
amcasey b5ef197
Add file symlink baselines
amcasey 41e9014
Add directory symlink baselines
amcasey 70e99f9
Update test to retain its meaning
amcasey f57ae39
Make VFSWithWatch.realpath use the path on disk
amcasey 2bccda7
Update VFS realpathSync to behave like realpathSync.native
amcasey b325dba
Use fs.realpathSync.native when available
amcasey fca073b
Rename SortedMap.getKeyAndValue to getEntry
amcasey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,27 +33,27 @@ export const Fragment: unique symbol; | |
| export const App = () => <div propA={true}></div>; | ||
|
|
||
| //// [/user/username/projects/myproject/tsconfig.json] | ||
| {"compilerOptions":{"jsx":"react-jsx","jsxImportSource":"react","forceConsistentCasingInFileNames":true},"files":["node_modules/react/Jsx-runtime/index.d.ts","index.tsx"]} | ||
| {"compilerOptions":{"jsx":"react-jsx","jsxImportSource":"react","forceConsistentCasingInFileNames":true},"files":["node_modules/react/jsx-Runtime/index.d.ts","index.tsx"]} | ||
|
|
||
|
|
||
| /a/lib/tsc.js --w --p . --explainFiles | ||
| Output:: | ||
| >> Screen clear | ||
| [[90m12:00:31 AM[0m] Starting compilation in watch mode... | ||
|
|
||
| [91merror[0m[90m TS1149: [0mFile name '/user/username/projects/myproject/node_modules/react/jsx-runtime/index.d.ts' differs from already included file name '/user/username/projects/myproject/node_modules/react/Jsx-runtime/index.d.ts' only in casing. | ||
| [91merror[0m[90m TS1149: [0mFile name '/user/username/projects/myproject/node_modules/react/Jsx-runtime/index.d.ts' differs from already included file name '/user/username/projects/myproject/node_modules/react/jsx-Runtime/index.d.ts' only in casing. | ||
| The file is in the program because: | ||
| Part of 'files' list in tsconfig.json | ||
| Imported via "react/jsx-runtime" from file '/user/username/projects/myproject/index.tsx' with packageId 'react/jsx-runtime/[email protected]' to import 'jsx' and 'jsxs' factory functions | ||
|
|
||
| [96mtsconfig.json[0m:[93m1[0m:[93m115[0m | ||
| [7m1[0m {"compilerOptions":{"jsx":"react-jsx","jsxImportSource":"react","forceConsistentCasingInFileNames":true},"files":["node_modules/react/Jsx-runtime/index.d.ts","index.tsx"]} | ||
| [7m1[0m {"compilerOptions":{"jsx":"react-jsx","jsxImportSource":"react","forceConsistentCasingInFileNames":true},"files":["node_modules/react/jsx-Runtime/index.d.ts","index.tsx"]} | ||
| [7m [0m [96m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m | ||
| File is matched by 'files' list specified here. | ||
|
|
||
| ../../../../a/lib/lib.d.ts | ||
| Default library | ||
| node_modules/react/Jsx-runtime/index.d.ts | ||
| node_modules/react/jsx-Runtime/index.d.ts | ||
| Part of 'files' list in tsconfig.json | ||
| Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/[email protected]' to import 'jsx' and 'jsxs' factory functions | ||
| index.tsx | ||
|
|
@@ -62,12 +62,12 @@ index.tsx | |
|
|
||
|
|
||
|
|
||
| Program root files: ["/user/username/projects/myproject/node_modules/react/Jsx-runtime/index.d.ts","/user/username/projects/myproject/index.tsx"] | ||
| Program root files: ["/user/username/projects/myproject/node_modules/react/jsx-Runtime/index.d.ts","/user/username/projects/myproject/index.tsx"] | ||
| Program options: {"jsx":4,"jsxImportSource":"react","forceConsistentCasingInFileNames":true,"watch":true,"project":"/user/username/projects/myproject","explainFiles":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} | ||
| Program structureReused: Not | ||
| Program files:: | ||
| /a/lib/lib.d.ts | ||
| /user/username/projects/myproject/node_modules/react/Jsx-runtime/index.d.ts | ||
| /user/username/projects/myproject/node_modules/react/jsx-Runtime/index.d.ts | ||
| /user/username/projects/myproject/index.tsx | ||
|
|
||
| No cached semantic diagnostics in the builder:: | ||
|
|
@@ -76,7 +76,7 @@ WatchedFiles:: | |
| /user/username/projects/myproject/tsconfig.json: | ||
| {"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250} | ||
| /user/username/projects/myproject/node_modules/react/jsx-runtime/index.d.ts: | ||
| {"fileName":"/user/username/projects/myproject/node_modules/react/Jsx-runtime/index.d.ts","pollingInterval":250} | ||
| {"fileName":"/user/username/projects/myproject/node_modules/react/jsx-Runtime/index.d.ts","pollingInterval":250} | ||
| /user/username/projects/myproject/index.tsx: | ||
| {"fileName":"/user/username/projects/myproject/index.tsx","pollingInterval":250} | ||
| /a/lib/lib.d.ts: | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the testcase missing that we discussed and is important change is when current directory is "c:/temp" but on disk it is "C:/Temp" and all realpath results with new API will differ in casing and give errors vs it wasn't giving earlier ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And may be it is ok for watch scenario but it is something that will impact tsserver and in turn vscode.. vscode keeps track of open files from previous session so not sure if that gets updated if you change the casing and restart vscode from directory but users will not be able to get rid of error easily unless they close all files if the casing is retained across sessions by vscode. You would need to experiment to figure that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to provide test coverage for drive root casing differences here. It's entirely possible I misunderstood your concerns though - please let me know if there's something else you'd like me to test.
From our offline discussion (before the break), I thought I understood that the watch VFS was the best place to add these tests. It sounds like you may be suggesting adding server tests as well. If that's the case, can you please point me at an example I can model them on?
I think you're saying that the paths returned by the server to VS Code might reflect the casing returned by realpathSync, but I'm not sure I understand what consequences you expect from this. If it's about re-opening files in a new session, I would have guessed VS Code used case-insensitive system calls to open them. If it's about VS Code passing stale paths back to the server when it starts a fresh instance, I would have guessed they would be re-normalized with an additional realpathSync call. Can you please elaborate on your concerns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test case also gives incorrect result? This should have been earlier been error and should be error because on case sensitive file system the import will not resolve, which is what intention of
forceConsistentFileNamesis..The case that it doesnt verify is also when the files on disk and all imports are consistent, but you start with current directory = different casing and build the project. Previously that would not error now it will ?
If the above scenario breaks for watch there is a way to fix those errors by closing tsc and restarting from correct casing directory. But what happens in vscode is question. vscode keeps list of open files, so is the solution to close all files and open editor again? Does restart work , depending on answers to that we may need coverage for some tests here to lock the expected behaviour for baselines. There are tests for these in
unittests\tsserver\forceConsistentCasingInFileNames.tsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the impression that
forceConsistentFileNamesignored drive roots. Sorry for not including a comment to that effect.I'm not sure I follow. Where is the current directory specified in this case?
So you'd just like me to manually verify that VS Code doesn't have obvious breaks if I close a folder, change the casing on disk, and re-open it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But your import doesnt test import "somethingsomething/a" and "somethingsomething/A" you would get error on either one of those and that was expected behavior which is not the current case.
Current directory need to be specified as part of the https://github.com/microsoft/TypeScript/pull/41292/files#diff-742ed890d46f805d54cbcf33f4a6f2cd286a81ac5df890b0b20636445b464093R149 . We need test where current directory differs in casing from whats on the disk.
The bigger missing part is import in wrong casing should give error which it wont because the realpath will resolve to casing on the disk and then we will loose that info. But same code in case sensitive file system will give error because import will not be resolved.
Disk file name: a.ts
import "a" > success
import "A" > will fail on case sensistive file systems... so it should error with forceConsistentFileCasing on case insensitive filesystem which it would not when realpath is invoked as part of this change.