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.
Fixes #27387
This is an implementation proposal for
@specialize
JSDoc tag, which will allow specifying type arguments in JS files. For example iff
has a type parameterT
, the following JSDoc syntax:will be equivalent to TS:
The tag can be also attached to any other parent node, e.g. assignment statement would also do:
Currently, it is also possible to wrap type arguments with
<...>
as in/** @specialize <number> */
,if that's the preference. I couldn't make up my mind so I allowed both options for now.
The following expressions are also supported:
I am still planning to add more unit tests, e.g.
Having said that, I've decided to open this PR early (as draft), because there are some open questions where I seek your advice:
@specialize
a good name for this tag? I was also considering@typeArgs
, which I think would be a little bit cleaner in communicating its purpose, but I don't like the fact that it consists of two words, as so far there has been no precedence.@specialize
is the fact that some people would prefer to spell it "specialise" and I am worried that it may cause confusion and typing errors in the future.