fix(language-service): Paths on Windows should be normalized #40492
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.
Many
ts.LanguageService
APIs accept a filename, for exampleThe requirement is that
fileName
is agnostic to the platform (Linux, Mac,Windows, etc), and is always normalized to TypeScript's internal
NormalizedPath
.This is evident from the way these APIs are called from the language server:
https://github.com/angular/vscode-ng-language-service/blob/9fca9c66510974c26d5c21b31adb9fa39ac0a38a/server/src/session.ts#L594
Here
scriptInfo.fileName
is always ats.server.NormalizedPath
.However, #39917 accidentally leaked
the platform-specific paths, and caused a mismatch between the incoming paths
and the paths stored in the internal data structure
TypeScriptServiceHost.fileToComponent
.This PR fixes the bug by always normalizing the paths, and updating the
type to reflect the format of the underlying data.
Fixes angular/vscode-ng-language-service#1063
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information