Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

blake-newman
Copy link

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.

Fixes #60125

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 9, 2024
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
@blake-newman blake-newman force-pushed the blake.newman/prevent-extra-file-extensions-being-stripped-out branch from c275e28 to f8cc8c7 Compare October 9, 2024 18:24
@blake-newman
Copy link
Author

@microsoft-github-policy-service agree company="Attest Technologies Limited"

@blake-newman blake-newman marked this pull request as ready for review October 10, 2024 08:14
@typescript-bot
Copy link
Collaborator

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"
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScriptKind.Deferred treated as LanguageVariant.Standard
2 participants