-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function type in union type not work? #39546
Comments
But this is OK(with brackets type fn = (param: number) => string
// works
type t1 = string | fn
// It's OK
type t2 = string | ((param: number) => string) This maybe confused, the same code express different meanings. type t2_maybe_1 = string
| (param: number) => string
| number
type t2_maybe_2 = string
| (param: number) => string | number |
Concerns over visual ambiguity. type Foo = () => string | () => number; could be parsed as type Foo = () => (string | () => number); which isn't always what people want. It doesn't protect against all the cases, but it's what we felt we could cover. The fact that you don't get a good error message - now that's a terrible experience... |
Check out #39548 to track making the error UX better here. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
@DanielRosenwasser Nice work, thx~ |
The text was updated successfully, but these errors were encountered: