TypeScript Type of generic function

后端 未结 2 1071
失恋的感觉
失恋的感觉 2021-02-20 01:52

I can\'t get my head arround the following paragraph in the TypeScript documentation:

\"The type of generic functions is just like those of non-generic functions, with t

2条回答
  •  臣服心动
    2021-02-20 02:37

    Lets say that from the compiler perspective explicit type declaration is not necessary because of type inference.

    let myIdentity: (arg: T) => T = identity;
    

    is equivalent to

    let myIdentity = identity
    

    Nevertheless, from the human side, it can be used for improving code readability.

提交回复
热议问题