tc39 / proposal-type-annotations

ECMAScript proposal for type syntax that is erased - Stage 1
https://tc39.es/proposal-type-annotations/
4.27k stars 47 forks source link

[grammar] Use a different syntax for type instantiation #189

Closed takikawa closed 1 year ago

takikawa commented 1 year ago

For the draft grammar, switch to using f::<T>(arg) syntax instead of f<T>(arg) syntax. Since this is in an expression context (instead of a type context), this explicit type instantiation is ambiguous with the < operator. This feedback came up during the March 2023 TC39 meeting.

I believe the ambiguity would come up with an example like this:

x < 4
5 > (y)

This can be parsed as

x < 4
^
MemberExpression
  ^^^
  TypeParamters
5 > (y)
^^^
TypeParameters
    ^^^
    Arguments

Or as RelationalExpressions.