Is there a way to compile TypeScript parameter type to type checking if
-statements to prevent runtime errors like this:
// TypeScript file
function test(param: string) {
return param.toUpperCase();
}
// should become JavaScript file
function test(param) {
if (typeof param !== "string") {
throw new Error("param must be of type 'string'");
}
return param.toUpperCase();
}