我想从JavaScript转换三个脚本到TypeScript。脚本可以在这个gist中找到。然而,我确实有一个我无法摆脱的错误。请注意,这是我的第一个React和TypeScript项目,所以我很容易就错过了一些明显的东西。我正在使用.tsx
文件和TypeScript 2.1。无法调用其类型缺少呼叫签名的表达式。键入'typeof'“''没有兼容的呼叫签名反应TypeScript
在文件:GoogleApiComponent.tsx
import * as cache from './ScriptCache'
...
componentWillMount() {
this.scriptCache = cache({ <--Error TS2349 here
google: GoogleApi({
apiKey: apiKey,
libraries: libraries
})
});
}
给了我这个错误:
Cannot invoke an expression whose type lacks a call signature. Type 'typeof "ScriptCache"' has no compatible call signatures.
ScriptCache.tsx
看起来是这样的:
let counter = 0;
let scriptMap = new Map();
export const ScriptCache = (function (global: any) {
return function ScriptCache(scripts: any) {
const Cache: any = {}
...
请举一个完整的例子。这也可能是由于你的模块导入/导出错误发生在哪一行。 –
@SebastianSebald你是对的,这是一个导入错误!非常感谢! – Ogglas