AnathanPham / blog

随便写写
1 stars 0 forks source link

ts函数类型定义有哪些方式? #70

Open AnathanPham opened 3 years ago

AnathanPham commented 3 years ago
  1. 一般形式

    function Play<Type>(game:Type):Type{
    // ...
    }
  2. 箭头函数

    type Play = <Type>(game:Type)=>Type
  3. 对象字面量 方便定义函数的静态属性

    type Play = {
    <Type>(game:Type):Type
    }