Closed
Description
Motivated by #39546
type Foo = string | () => string;
type InstOrConst<T> = T | new () => T;
We made a decision to disallow function and constructor shorthand types in these contexts, but as a result we have really poor error recovery.
Exported type alias 'Foo' has or is using private name ''.(4081)
Type expected.(1110)
';' expected.(1005)
'string' only refers to a type, but is being used as a value here.(2693)
Cannot find name 'new'.(2304)
Exported type alias 'InstOrConst' has or is using private name 'new'.(4081)
';' expected.(1005)
Cannot find name 'T'.(2304)
We should be able to issue an error in these contexts:
Function type notation must be parenthesized when used in a union type.
Constructor type notation must be parenthesized when used in a union type.