我正在尝试编译一个基本项目,并在我的库中包含lodash。根据Typescript 3.0文档,这应该可以工作。
package.json
{
...
"dependencies": {
"lodash": "4.17.10",
"npm-run-all": "4.1.2",
"typescript": "3.0.1"
}
...
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"outDir": "./dist/out-tsc",
"typeRoots": [
"./node_modules/@types/"
]
},
"include": [
"src/**/*.ts",
"node_modules/@types"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
types
也会发生同样的事情。根据google搜索,我的组件必须包含typeRoots
才能使用types
或lodash
。我想念什么?
答案 0 :(得分:0)
我的答案:
{
"compilerOptions": {
"strict": true,
"module": "commonjs",
"target": "ESNext",
"noImplicitAny": true,
"typeRoots": ["app/types/*","./node_modules/@types","../../node_modules/@types",],
"types":["node","jest"],
"moduleResolution": "node",
"baseUrl": "./",
"sourceMap": false,
"esModuleInterop": true,
"experimentalDecorators":true,
"forceConsistentCasingInFileNames":true,
"strictPropertyInitialization":false,
"outDir": "build"
},
"include": ["./app/**/*"],
"exclude": ["node_modules", "./__tests__/*"]
}