switch type guarding with satisfies
This commit is contained in:
parent
2d0745f9ec
commit
217d6c7982
5 changed files with 13 additions and 11 deletions
|
|
@ -203,7 +203,7 @@ export const IconMatrix = ({ type, ...rest }: IconMatrixProps) => {
|
||||||
case "thumbs-up":
|
case "thumbs-up":
|
||||||
return <ThumbsUp {...rest} />;
|
return <ThumbsUp {...rest} />;
|
||||||
default:
|
default:
|
||||||
return <div>Icon not found</div>;
|
throw new Error(`Invalid icon type: ${type satisfies never}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ function createStore(
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
throw new Error(`Unhandled action type: ${action satisfies never}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1291,7 +1291,7 @@ function FileUploadItemProgress(props: FileUploadItemProgressProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
case "linear":
|
||||||
return (
|
return (
|
||||||
<ItemProgressPrimitive
|
<ItemProgressPrimitive
|
||||||
aria-labelledby={itemContext.nameId}
|
aria-labelledby={itemContext.nameId}
|
||||||
|
|
@ -1315,6 +1315,8 @@ function FileUploadItemProgress(props: FileUploadItemProgressProps) {
|
||||||
/>
|
/>
|
||||||
</ItemProgressPrimitive>
|
</ItemProgressPrimitive>
|
||||||
);
|
);
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown variant: ${variant satisfies never}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,8 @@ const MapComp = ({
|
||||||
</CustomMarker>
|
</CustomMarker>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
default:
|
||||||
|
throw new Error(`Invalid marker type: ${markerType satisfies never}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,5 +148,7 @@ export const PaymentMethodToString = (type: PaymentType) => {
|
||||||
return "WeChat Pay";
|
return "WeChat Pay";
|
||||||
case "zip":
|
case "zip":
|
||||||
return "Zip";
|
return "Zip";
|
||||||
|
default:
|
||||||
|
throw new Error(`Invalid payment type: ${type satisfies never}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -183,13 +183,9 @@ export const genMail = async ({ ...mail }: MailsTemplates) => {
|
||||||
title = "Invito al sito";
|
title = "Invito al sito";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mailComponent = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mailComponent === null) {
|
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "INTERNAL_SERVER_ERROR",
|
code: "INTERNAL_SERVER_ERROR",
|
||||||
message: "Errore nella creazione dell'email",
|
message: `Tipo di email non valido: ${mail satisfies never}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue