Type Keyword 是 typescript 能將型別取一個別名的方式,例如我將型別 string assign 給 myType,之後就可以用 myType 來定義變數的型別。

type keyword
  • ts
1
2
3
type myType = string;
let a: myType = 'hello';
let b: myType = 10; // Type 'number' is not assignable to type 'string'

Continue reading
  • page 1 of 1
Author's picture

Miles

I’m a person who is enthusiastic about Coding, and that’s my job by the way.


Web Developer


Taiwan