-
Notifications
You must be signed in to change notification settings - Fork 215
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
Suggestion: how about &
for overloaded method type separator, instead of |
?
#566
Comments
Here's an example of this in Typescript type FType = ((a: number) => void) | ((a: string) => void)
const f: FType = (a: number | string) => {}
f(42)
type GType = ((a: number) => void) & ((a: string) => void)
const g: GType = (a: number | string) => {}
g(42) The |
Closing this issue because it seems this issue was too late to change syntax. |
I'm sorry that I didn't notice this issue. Yes, I think it's too late and I won't change the syntax to I don't remember why I made |
Sorry for the necropost. The choice for However, on deeper contemplation,
This is the same science as how |
Current syntax of overloaded method type looks like a union of function types. However, type of overloaded method behaves like an intersection of function types in typical type system.
I suggest to change the separator from
|
to&
for consistency.For example, there is a method
f
that is overloaded like this:If
f
has an intersection of function types, type check off 42
passes like this:f "hello"
is also okay.If union, it doesn't. It's unsure whether
f
can take an integer. This is an example written in lambda calculus with subtyping:The text was updated successfully, but these errors were encountered: