You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One option would be to prevent inference of a union here, but I am not interested in semantics here. Rather, I am interested in a parsing issue.
f<T>(x) is currently a valid program in JS. Specifically, it's a nested binary expression ((f<T)>x), which is a fairly useless parse tree IMO, but a parse tree nonetheless.
Note that TypeScript interprets f<T>(x) as a call expression, departing from JS in this small way. Flow has held off on this feature, due to the parser ambiguity, but we would very much like to support this use case.
Given a type system with generics+inference+union types, it's useful to be able to instantiate the type parameters at a call site.
For example, a function with two generic arguments
T
might be inferred as a union of two unrelated types if called without a specific instantiation.One option would be to prevent inference of a union here, but I am not interested in semantics here. Rather, I am interested in a parsing issue.
f<T>(x)
is currently a valid program in JS. Specifically, it's a nested binary expression((f<T)>x)
, which is a fairly useless parse tree IMO, but a parse tree nonetheless.Note that TypeScript interprets
f<T>(x)
as a call expression, departing from JS in this small way. Flow has held off on this feature, due to the parser ambiguity, but we would very much like to support this use case.Ref #6
The text was updated successfully, but these errors were encountered: