Angular2 + Webpack,Typescrip @ 2.1.4,Visual Studio 2015 as IDE。
我需要将外部声明文件(将其命名为extlib
)添加到我的项目中,@types
包中未提供。我做了以下事情:
将extlib.d.ts
移至typings/extlib/index.d.ts
;
修改tsconfig.json
如下;
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": true,
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"./node_modules/@types",
"./typings"
],
"types": [
"node",
"howler",
"extlib"
]
},
"files": [
"app/app.module.ts",
"main.ts"
],
"awesomeTypescriptLoaderOptions": {
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false
}
在ts文件中使用extlib
:
import * as extlib from 'extlib'
这样做之后,VS的智能感知效果很好,tsc也是如此。但是当我使用webpack时,它告诉我:
`Module not found: Error: Can't resolve 'extlib' in '...'`
如何使webpack解析此外部打字稿声明文件?