我的代码:
'use strict';
import {_ as underscore} from 'underscore';
当我导入软件包“下划线”时,出现一个这样的TSC错误:
app/util/global.ts(7,10): error TS2305: Module '"F:/newVRMMO/node_modules/@types/underscore/index"' has no exported member '_'.
下划线/index.d.ts:
declare var _: _.UnderscoreStatic;
export = _;
export as namespace _;
declare global {
interface Element { }
}
declare module _ {
interface ThrottleSettings {
leading?: boolean;
trailing?: boolean;
}
...
...
...
}
我不知道为什么会出现此错误。
答案 0 :(得分:1)
对不起,是我的错,导入错误:
import {_ as underscore} from 'underscore';
正确的导入方式是:
import * as underscore from 'underscore';