We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
type, union, rest
allow rest operator on a union type when all cases are array
in order to declare a ctor with overloads, I wrote something like this
type TimeSpanCtorArguments = [number] | [number, number, number] | [number, number, number, number] | [number, number, number, number, number]; class TimeSpan { private readonly _ticks: number; constructor(...args: TimeSpanCtorArguments) { if (typeof args.length === 1) { [this._ticks] = args; } else if (args.length === 3) { const [hours, minutes, seconds] = args; } else if (args.length === 4) { const [days, hours, minutes, seconds] = args; } else { const [days, hours, minutes, seconds, milliseconds] = args; } } }
I get the error: [ts] A rest parameter must be of an array type.
[ts] A rest parameter must be of an array type.
on the line
constructor(...args: TimeSpanCtorArguments) {
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered:
might be related to #15972
Sorry, something went wrong.
@RyanCavanaugh any update on this?
@RyanCavanaugh this already works since 3.3 so the issue can be closed: TS 3.3 playground
No branches or pull requests
Search Terms
type, union, rest
Suggestion
allow rest operator on a union type when all cases are array
Use Cases
in order to declare a ctor with overloads, I wrote something like this
I get the error:
[ts] A rest parameter must be of an array type.
on the line
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: