Add async
ness to semantic highlighting
#57593
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
"expose type syntax highlight", "semantic syntax highlighting for promise", "highlight variables based on type"
β Viability Checklist
β Suggestion
Expose (some) type information to the syntax highlighter for semantic styling so we can highlight variables / function calls of particular types.
π Motivating Example
Hungarian notation has long since marked as something to be avoided, yet a common practice I see is naming async functions with an
Async
suffix, or with anawait
prefix.This indicates that whether or not something returns a promise is important enough that we're marking async functions with these prefixes/suffixes.
Hungarian notation went away because IDE's improved and we could start to rely on it to give us type information (on hover) and via type checking.
While researching this I stumbled upon the semantic highlighting config in VSCode and decided to take a leaf out of rusts book which underlines
mut
values and tried to apply an underline to any variableT
whereT extends Thenable<any>
.However the best I could get was to mark functions tagged as async as this is the only information available to the syntax highlighter (as seen by running the "Developer: Inspect Editor Tokens and Scopes" command)
But this falls over in a few places
It also doesn't do anything for thenable valued variables
In my head, the ideal situation is that a textmate modifier is added to any variable whose value (or method whose return type) exclusively extends
Promise
(orThenable
). That wayprom
would be underlined.I understand there will be some complexities and many edge cases for figuring this out; its not necessarily true that
Promise
refers to a promiseor
also
There may be ways around these problems (maybe something like
T extends Promise<any> ? Promise<any> extends T ? true : false : false
)π» Use Cases
The text was updated successfully, but these errors were encountered: