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

[TypeScript] Keyword types can't be generic #3863

Merged

Conversation

Thom1729
Copy link
Collaborator

Fix #3862.

Originally, type arguments were part of the regular type expression structure, so the syntax would try to highlight type arguments after any type. But actually, only ordinary named types can get them. In the linked issue, this was causing problems with as-style type assertions — when followed by a <, the type expression was eating it and trying to parse type arguments, even when the preceding type does not accept them.

According to the spec — I'm kidding, we all know the drill by now, actually after a bunch of futzing around in AST Explorer — this should work correctly in all cases I can think of.

In order for this to work in all cases, it's necessary to ensure that all specially keyworded types are accounted for, so this PR also adds the true and false singleton types.

@Thom1729
Copy link
Collaborator Author

Put back generic parameters in namespaced types. Also added some plain-TS tests for those, which were apparently overlooked.

@deathaxe deathaxe merged commit 83b037b into sublimehq:master Oct 31, 2023
2 checks passed
@Thom1729 Thom1729 deleted the typescript-primitives-cant-be-generic branch October 31, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JavaScript] TypeScript cast throws off further highlighting
4 participants