📜  类型脚本元组类型 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:22.652000             🧑  作者: Mango

代码示例1
// Declare a tuple type
let x: [string, number];
// Initialize it
x = ["hello", 10]; // OK
// Initialize it incorrectly
x = [10, "hello"]; // Error
Type 'number' is not assignable to type 'string'.Type 'string' is not assignable to type 'number'.23222322Type 'number' is not assignable to type 'string'.Type 'string' is not assignable to type 'number'.Try