-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
feat: allow explicit ScriptKind extraFileExtensions #60178
base: main
Are you sure you want to change the base?
feat: allow explicit ScriptKind extraFileExtensions #60178
Conversation
When configuring the language service host with extra file extensions, the file extension is only regarded as supported if its `Deferred` or like JS. If the host can delare a specific ScriptKind such as `TSX` for a file then it will be stripped out with getSupportedExtensions. This then later causes the programs rootFiles to not include the extra file extension, and thus be excluded from the program. If using `Deferred` then the file when parsed will be treated as TS and fail to compile when using (J)TSX syntax. In majority of cases the script kind will be known by the consumer and they can set the explicit script kind for the extra file extension. Adjust the logic for `getSupportedExtensions` to include any extra file extension that are not built in. This way all explicit extra file extensions added will be included in the project/programs root files and an explicit `scriptKind` can be set. resolves: microsoft#60125
c275e28
to
f8cc8c7
Compare
@microsoft-github-policy-service agree company="Attest Technologies Limited" |
The TypeScript team hasn't accepted the linked issue #60125. If you can get it accepted, this PR will have a better chance of being reviewed. |
@@ -595,7 +603,8 @@ Info seq [hh:mm:ss:mss] Creating ConfiguredProject: /user/username/projects/pro | |||
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/tsconfig.json 2000 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Config file | |||
Info seq [hh:mm:ss:mss] Config: /user/username/projects/project/tsconfig.json : { | |||
"rootNames": [ | |||
"/user/username/projects/project/f1.ts" | |||
"/user/username/projects/project/f1.ts", | |||
"/user/username/projects/project/f2.html" |
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.
This seems to be legit, based on the issue. Extensions marked as anything but Deferred where not considered as part of the root of project.
When configuring the language service host with extra file extensions, the file extension is only regarded as supported if its
Deferred
or like JS. If the host can delare a specific ScriptKind such asTSX
for a file then it will be stripped out with getSupportedExtensions.This then later causes the programs rootFiles to not include the extra file extension, and thus be excluded from the program.
If using
Deferred
then the file when parsed will be treated as TS and fail to compile when using (J)TSX syntax. In majority of cases the script kind will be known by the consumer and they can set the explicit script kind for the extra file extension.Adjust the logic for
getSupportedExtensions
to include any extra file extension that are not built in. This way all explicit extra file extensions added will be included in the project/programs root files and an explicitscriptKind
can be set.Fixes #60125