Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript &引用;找不到模块“的声明文件”;当模块位于tsconfig路径中时_Typescript - Fatal编程技术网

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/标记它
打字