我收到Invalid module name in augmentation
来自 webpack 的错误,因为*.d.ts
我的项目中包含了几个库文件。
一个示例来自 Leaflet-draw,它的 d.ts 文件顶部有以下模块声明:
import * as L from 'leaflet';
declare module 'leaflet' {
interface MapOptions {
drawControl?: boolean;
}
完整的错误是:
扩充中的模块名称无效。模块 'leaflet' 解析为位于 'C:\Users***\Documents\GitHub***\node_modules\leaflet\dist\leaflet-src.js' 的无类型模块,该模块无法扩充。
我不完全确定该怎么做,我不想自己修改 d.ts 文件,因为这些文件是在外部维护的。
我正在使用最新版本的 webpack (3.11.0) 和 ts-loader (3.5.0)。
我的 tsconfig 编译器选项如下:
"compilerOptions": {
"target": "es5",
"sourceMap": true,
"outDir": "./dist",
"rootDir": "../",
"noImplicitAny": false,
"noImplicitThis": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"pretty": true,
"removeComments": false,
"allowUnreachableCode": false,
"declaration": false,
"allowJs": true,
"module": "commonJs",
"typeRoots" : ["./typings/index.d.ts", "../../node_modules/@types"]
}
感谢任何人提供的任何帮助,以帮助我进一步了解错误以及如何解决它。
谢谢