You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Property 'clientForNumbersIs' in type 'anyTuple<size>' is not assignable to the same property in base type 'tuple<size>'.
Type '(client: (...numbers: number[] & { length: size; }) => void) => void' is not assignable to type '(...numbers: number[] & { length: size; }) => void'.
Types of parameters 'client' and 'numbers' are incompatible.
Property '0' is missing in type 'number[] & { length: size; }' but required in type '[client: (...numbers: number[] & { length: size; }) => void]'.
Argument of type 'number[]' is not assignable to parameter of type 'number[] & { length: size; }'.
Type 'number[]' is not assignable to type '{ length: size; }'.
Types of property 'length' are incompatible.
Type 'number' is not assignable to type 'size'.
'size' could be instantiated with an arbitrary type which could be unrelated to 'number'.
Argument of type '(n1: number, n2: number, n3: number) => void' is not assignable to parameter of type '(...numbers: number[] & { length: 3; }) => void'.
Types of parameters 'n1' and 'numbers' are incompatible.
Type 'number[] & { length: 3; }' is not assignable to type '[n1: number, n2: number, n3: number]'.
However, from my point of view, there is no problem with type because this.numbers in anyTuple match requirement of interface tuple, and it is the same for this.numbers from triplet instance.
So, i see two options:
I haven't understood in the right way the type checking algorithm or its philosophy;
There is a problem in the type checking algorithm in this context.
So, is there someone here to show me the light ;), or confirm the bogus behavior?
π Expected behavior
No error.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
spread, argument, union, type.
π Version & Regression Information
It is a "strange" and maybe abnormal behavior of type checking algorithm when union is used on function/method argument with spread operator.
β― Playground Link
https://www.typescriptlang.org/play/?#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDjAVzABtgAeAZwQC9gA+OAbwCg425tiFgUAxaAHIEAtgCM0FAJIUAFADoFcJCPFQKALiUq0AbQC6cAGRM4pJAHMYAC01VacAL4BKTQDcICACYBuZg+bMnJgUFHCYSACeACpEpJQ09IjCJMDCPDChhCnxtAws7HBgUAiumKhaYhKaypVQ+kYmZpY2cHZ4Dr6s7NgQSBQwUATYMNDyijWqGhWq9caMpjzNtglwTkxdBWzWCBRyExJwALzTEr4F-hscXOn8UEK1UrKc3CiaY3InatXadQZzCxZrMt7M4jgx3F4XHAIZ51ptutcUO98FYdnsfhQnGd2P4LkEQvhiil4KBUEhPKFwtFYuQAMx5S49PoDIYjKAyJAARm+tSOcAADAAaJQAJh5qj5QqUtPFaEla3y8NaRDQHM5wqQIo1tKxl1xASZ-TgnmAWAIxBgUSJpHgxyQwAA7oSEMSZLrmCazRarS6bZc5M8boIMdIZJcCmqNVrpWtDnkOL0KBBSHJiBBzJHRdqsY5Lk5mN4gA
π» Code
π Actual behavior
The code generate these following errors:
However, from my point of view, there is no problem with type because
this.numbers
inanyTuple
match requirement of interfacetuple
, and it is the same forthis.numbers
fromtriplet
instance.So, i see two options:
So, is there someone here to show me the light ;), or confirm the bogus behavior?
π Expected behavior
No error.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: