在打字稿中找不到'autobind-decorator'的声明文件
我正在使用Typescript,我想在项目中导入'autobind-decorator'包,但我卡在这里。
编译时出现这个错误行:
找不到“autobind-decorator”的声明文件。 隐含有一个“任何”types
我也试过@types/autobind-decorator
npm包,但是没有成功。 有没有select摆脱这个编译错误?
这是我的tsconfig:
{ "version": "2.1.5", "compilerOptions": { "module": "commonjs", "lib": ["es2015", "es2016", "dom"], "sourceMap": true, "noImplicitAny": true, "target": "es6", "jsx": "react", "skipLibCheck": true, "experimentalDecorators": true }, "include": [ "./packages/ld-web/src/**/*" ], "exclude": [ "**/node_modules", "**/*.d.ts" ] }
导入:
import * as autobind from "autobind-decorator";
从这里的types声明中声明并导出为模块,
您需要将@types
安装为:
npm install @types/autobind-decorator --save-dev
并导入为:
import autobind = require("autobind-decorator");