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
Expected behavior:
It compiles Actual behavior:
Compile time error:
Property 'findBoxes'intype'Box<T>' is not assignable to the same property in base type'ICanFindBoxes'.
Type '<T extends AllBoxes, K extends string>(boxName: K) => T extends { type: K; } ? T[] : never' is not assignable to type'<T extends AllBoxes, K extends string>(boxName: K) => T extends { type: K; } ? T[] : never'. Two different types with this name exist, but they are unrelated.
Type '(T extends { type: K; } ? T[] : never) | ({ type: K; } & ABox)[] | ({ type: K; } & BBox)[]' is not assignable to type'T extends { type: K; } ? T[] : never'.
Type '({ type: K; } & ABox)[]' is not assignable to type'T extends { type: K; } ? T[] : never'.
11 public findBoxes<T extends AllBoxes, K extends string>(boxName: K): T extends { type: K } ? T[] : never {
The compiler is incorrectly identifying that the signatures are different when they are not. If I simplify the union type to only one it works (but this defeats the purpose of the signature).
This was working in < 3.4.1
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms: Type inference, discriminated union types
Code
Expected behavior:
It compiles
Actual behavior:
Compile time error:
The compiler is incorrectly identifying that the signatures are different when they are not. If I simplify the union type to only one it works (but this defeats the purpose of the signature).
This was working in < 3.4.1
The text was updated successfully, but these errors were encountered: