-
Notifications
You must be signed in to change notification settings - Fork 248
Closed
Description
I sometimes get a type error in the fromDataUnion(data) method in the switch expression :
static fromDataUnion(data: RoleUnion): RoleUnion {
if (!data) {
return data;
}
switch (data.role) {
case "ROLE_A":
return RoleA.fromData(data);
case "ROLE_B":
return RoleB.fromData(data);
case "ROLE_C":
return RoleC.fromData(data); // here
...
I had to add a cast to make it work :
RoleC.fromData(<RoleC> data);
Maybe we could add automatically this cast in every switch case to avoid type errors ?
Metadata
Metadata
Assignees
Labels
No labels