好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

TypeScript type 类型别名

  //6,类型别名
   /**类型别名不能出现在声明右侧的任何地方。
    * 接口 vs. 类型别名
    * 另一个重要区别是类型别名不能被extends和implements(自己也不能extends和implements其它类型)。
    * 因为 软件中的对象应该对于扩展是开放的,但是对于修改是封闭的,你应该尽量去使用接口代替类型别名。
    * 另一方面,如果你无法通过接口来描述一个类型并且需要使用联合类型或元组类型,这时通常会使用类型别名。*/
  type  Int  = ( a : number)  => {} ;
 type  Name  = string ;
 type  NameResolver  = ()  => string ;
 type  NameOrResolver  =  Name  |  NameResolver ;                             

查看更多关于TypeScript type 类型别名的详细内容...

  阅读:50次