在通用箭头函数内调用通用函数时出现错误TS2304

问题描述 投票:0回答:1

为什么Typescript在尝试使用提供的type参数从箭头函数调用泛型函数时引发错误。

function a<T>() { }
function b<T>() { a<T>() } // no errors
const c: <T>() => void = () => a<T>() // cannot find name T. ts(2304)
typescript generics arrow-functions
1个回答
0
投票

因为您在c的类型定义中声明了T。那应该是它的外观]

© www.soinside.com 2019 - 2024. All rights reserved.