Closed aleclarson closed 6 years ago
I don't have tuples in the language because lightweight records are better, I don't think it needs a type syntax.
Is there no concept of an argument list? Or would that be a record, too?
In the case of:
fn (...rest) {}
rest
is a fixed length array with the type Array<T>
where T
is the union of all the types of values in rest
Clobbering the order would remove type-safety from rest-then-spread-call.
type Foo = fn (a: number, b: string): number
type Bar = fn (a: string, b: number): number
// Are the type declarations are required here?
let bar: Bar = fn (...args) { 1 }
let foo: Foo = fn (...args) {
bar(...args) // no compiler error, yet [number, string] and [string, number] are incompatible
}
Well there would be compiler errors because Number | String
cannot flow into Number
or String
So rest-then-spread is not possible? If so, what's the workaround?
I assume it's just: