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'
最近專案上有使用到 Sweetalter2 ,可是目前 typescript 的 typing 檔案,只有 Sweetalter 的版本,導致有很多屬性在使用的時候,typescript 看不懂,例如 input 這個屬性。
- ts
1 | swal({ |