我有一个项目,其中包含一些类似的类:
(示例代码 - 实际代码当然看起来不同)
class TestController {
public static $inject = [
'$scope',
];
public static $component: ng.IComponentOptions = {
templateUrl: template,
controller: TestController,
};
public constructor(
private $scope: angular.IScope,
) {
}
}
export default TestController .$component;
当我使用SystemJS加载依赖项时,在运行tsc和gulp时这完全没问题。
但是在切换到webpack之后,这只会在WEBPACK中引发错误:
ERROR in ./src/somepath/test.ts
(..,..): error TS2503: Cannot find namespace 'TestController'.
这看起来像打字稿编译器与webpack结合使用的问题。
修改:已添加tsconfig.json
{
"compilerOptions": {
"rootDir": ".",
"outDir": "../wwwroot",
"target": "es5",
"module": "es6",
"lib": [
"DOM",
"ES5",
"ScriptHost",
"ES2015.Core",
"ES2015.Iterable",
"ES2015.Collection",
"ES2015.Promise"
],
"moduleResolution": "node",
"isolatedModules": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noLib": false,
"preserveConstEnums": true,
"sourceMap": true,
"newLine": "LF",
"removeComments": false,
"suppressImplicitAnyIndexErrors": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noEmitHelpers": true,
"importHelpers": true,
"allowSyntheticDefaultImports": true
}
}