Typescript &引用;找不到模块“的声明文件”;当模块位于tsconfig路径中时
我在一个角度项目中使用。我在我的Typescript &引用;找不到模块“的声明文件”;当模块位于tsconfig路径中时,typescript,Typescript,我在一个角度项目中使用。我在我的package.json中安装了markdown it和@types/markdown it作为依赖项。我想在构建捆绑包时拉入缩小的文件,因此我在我的tsconfig的路径数组中添加了一个条目: [tsconfig.json] { "compilerOptions": { "importHelpers": true, "sourceMap": true, "declaration": false, "moduleResoluti
package.json
中安装了markdown it
和@types/markdown it
作为依赖项。我想在构建捆绑包时拉入缩小的文件,因此我在我的tsconfig的路径
数组中添加了一个条目:
[tsconfig.json]
{
"compilerOptions": {
"importHelpers": true,
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"target": "es2015",
"noUnusedLocals": true,
"noImplicitAny": true,
"noImplicitThis": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"alwaysStrict": true,
"typeRoots": [
"node_modules/@types",
"../../node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"baseUrl": ".",
"paths": {
"markdown-it": [
"node_modules/markdown-it/dist/markdown-it.min.js",
]
},
"module": "esnext"
},
"angularCompilerOptions": {
"enableIvy": false
},
"exclude": [
"node_modules",
"tmp"
]
}
但是,在我的组件typescript文件中执行以下操作时:
import MarkdownIt from 'markdown-it';
我得到这个错误:
Could not find a declaration file for module 'markdown-it'. '...../node_modules/markdown-it/dist/markdown-it.min.js' implicitly has an 'any' type.
2 import MarkdownIt from 'markdown-it';
如果没有tsconfig
中的paths条目,则不会发生错误,但显然不会像我所希望的那样拉入缩小的文件。如何使用路径
别名,同时告诉typescript使用@types/标记它
打字