Type Keyword 是 typescript 能將型別取一個別名的方式,例如我將型別 string
assign 給 myType,之後就可以用 myType 來定義變數的型別。1
2
3type myType = string;
let a: myType = 'hello';
let b: myType = 10; // Type 'number' is not assignable to type 'string'
Type Keyword 是 typescript 能將型別取一個別名的方式,例如我將型別 string
assign 給 myType,之後就可以用 myType 來定義變數的型別。1
2
3type myType = string;
let a: myType = 'hello';
let b: myType = 10; // Type 'number' is not assignable to type 'string'
I’m a person who is enthusiastic about Coding, and that’s my job by the way.
Web Developer