我不知道这到底是怎么了,为什么TS会抱怨。我一定会错过一些我不了解的TS:
App.js
function fullName(firstName: string, lastName: string): string {
return `${firstName} ${lastName}`;
}
function toUser(view: any, body: any, emailAddress: any) {
const fullName: string = fullName(firstName, lastName);
...
}
错误:
Type 'String' has no call signatures.
86 const fullName: string = fullName(firstName, lastName);
TS2448: Block-scoped variable 'fullName' used before its declaration.
86 const fullName: string = fullName(firstName, lastName);
const fullName: string = fullName(firstName, lastName);
~~~~~~~~
'fullName' is declared here.
error TS2454: Variable 'fullName' is used before being assigned.
86 const fullName: string = fullName(firstName, lastName);
答案 0 :(得分:2)
函数和变量具有相同的名称。您正在屏蔽该功能。