安全
TypeScript 通過靜態分析儘早捕獲型別錯誤:
function double(x: number): number {
return 2 * x;
}
double('2');
// ~~~ Argument of type '"2"' is not assignable to parameter of type 'number'.
TypeScript 通過靜態分析儘早捕獲型別錯誤:
function double(x: number): number {
return 2 * x;
}
double('2');
// ~~~ Argument of type '"2"' is not assignable to parameter of type 'number'.