打字稿无法解析类型
typescript unable to resolve type
我正在尝试在一个项目中使用 log4javascript,我看到该包在 node_modules/log4javascript/ 中确实有 log4javascript.d.ts,并且 package.json 在 "typings" 属性 但是在编译我的项目时它会抱怨:
S2307: Cannot find module 'log4javascript'
我正在导入模块使用:
import {getLogger } from 'log4javascript';
据我了解,不需要单独安装类型:
npm install @types/log4javascript
因为输入已经存在。但是我不确定如果我有:
我该如何使用模块类型和方法
"noImplicitAny": true,
设置在我的tsconfig.json
我的 tsconfig.json 看起来像:
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"target": "es2015",
"declaration": true
},
"include": [
"static/js/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
我正在尝试在一个项目中使用 log4javascript,我看到该包在 node_modules/log4javascript/ 中确实有 log4javascript.d.ts,并且 package.json 在 "typings" 属性 但是在编译我的项目时它会抱怨:
S2307: Cannot find module 'log4javascript'
我正在导入模块使用:
import {getLogger } from 'log4javascript';
据我了解,不需要单独安装类型:
npm install @types/log4javascript
因为输入已经存在。但是我不确定如果我有:
我该如何使用模块类型和方法"noImplicitAny": true,
设置在我的tsconfig.json
我的 tsconfig.json 看起来像:
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"target": "es2015",
"declaration": true
},
"include": [
"static/js/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}