【发布时间】:2020-04-03 20:01:00
【问题描述】:
问题来了:我想做一个函数,获取参数并返回相同的类型。
我做了一个最简单的例子:
type Test = <T>(arg: T) => T;
const test: Test = (arg: string) => arg;
Test 类型函数的这个简单实现抛出错误“Type 'T' is not assignable to type 'string'”
有人可以解释一下为什么在不使用模板参数中的道具时会发生此错误事件吗?
【问题讨论】: