Typescript, adding keywords satisfies and as to the lexer #2014
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.
Howdy!
Noticed some less than perfect syntax highlighting on a blog post, and thought to fix the issue upstream in rouge.
In typescript, 'as' and 'satisfies' are type assertion operator, while 'satisfies' is a type operator. There is no 'as' keyword in javascript, and the way the rule was written, functions named "as" were being marked as keywords, rather than functions.
I took the rule from a textmate grammar, and modified it to work in rouge.
I also tested this commit against my blog, and noticed the improved syntax highlighting there.
Now, "satisfies" and "as" are marked as keywords where they are used in a keyword way.
Here are three screenshots, before, after, and delta of visual lexer test.
Before
The "satisfies" is not bolded, and the "as" in the function names are bolded. Not ideal.
After
The "satisfies" is bolded, and the function names are not bolded, with no regressions to the other "as"
Delta
white is unchanged, teal is text that was made unbolded, and yellow is bolded.