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
classEntity{id: number;}classBaseClass{constructor(){}testMethod(single: Entity): Entity;testMethod(multiple: Entity[]): Entity[];testMethod(singleOrMultiple: Entity|Entity[]): Entity|Entity[]{returnsingleOrMultiple;}testTwo(single: Entity): Entity;testTwo(multiple: Entity[]): Entity[];testTwo(singleOrMultiple: Entity|Entity[]): Entity|Entity[]{returnsingleOrMultiple;}}classSubClassextendsBaseClass{testMethod(single: Entity): Entity;testMethod(multiple: Entity[]): Entity[];testMethod(singleOrMultiple: Entity|Entity[]): Entity|Entity[]{// Argument of type 'Entity | Entity[]' is not assignable to parameter of type 'Entity[]'.// Type 'Entity' is not assignable to type 'Entity[]'.// Property 'includes' is missing in type 'Entity'.returnsuper.testMethod(singleOrMultiple);}testTwo(single: Entity): Entity;testTwo(multiple: Entity[]): Entity[];testTwo(singleOrMultiple: Entity|Entity[]): Entity|Entity[]{// if I manually narrow to array or not, the compiler doesn't complainif(Array.isArray(singleOrMultiple)){returnsuper.testTwo(singleOrMultiple);}else{returnsuper.testTwo(singleOrMultiple);}}}
Expected behavior:
Since the signatures are identical, I would expect the compiler to choose the proper overload of the super method
Actual behavior:
Compiler chooses the wrong overload signature.
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.7.2
Search Terms:
overload signature super union
Code
Expected behavior:
Since the signatures are identical, I would expect the compiler to choose the proper overload of the super method
Actual behavior:
Compiler chooses the wrong overload signature.
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: