arg是number类型 那arg+1肯定是number类型。函数返回值Type 也对吧。
为什么报错呢
function identity<Type>(arg: Type): Type { if(typeof arg === 'number' ){ //Type 'number' is not assignable to type 'Type'. // 'Type' could be instantiated with an arbitrary //type which could be unrelated to 'number'. return arg + 1 }else { return arg } }

看图就很容易理解了,比如你传入的是 1 ,那么其实最终的返回值也为 1,而当符合你的 type arg === ‘number’ 时,你对其进行了 + 1 ,此时为 2 和推断的结果本身就是不一致的。
你疑惑的点其实是先入为主认为,只要你传入数字类型就会被推断为 number 了。