Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
&引用;TS2503:找不到命名空间";尝试通过网页包导出Typescript中的默认值时_Typescript_Webpack - Fatal编程技术网

&引用;TS2503:找不到命名空间";尝试通过网页包导出Typescript中的默认值时

&引用;TS2503:找不到命名空间";尝试通过网页包导出Typescript中的默认值时,typescript,webpack,Typescript,Webpack,我有一个项目,其中有些类是这样写的: (示例代码-实际代码看起来当然不同) 当我使用SystemJS加载依赖项时,在运行tsc和gulp时,这一点符合得非常好 但是,切换到webpack后,这只会在webpack中引发错误: ERROR in ./src/somepath/test.ts (..,..): error TS2503: Cannot find namespace 'TestController'. 在我看来,这似乎是typescript编译器与webpack结合的问题 编辑:添加

我有一个项目,其中有些类是这样写的:
(示例代码-实际代码看起来当然不同)

当我使用SystemJS加载依赖项时,在运行tsc和gulp时,这一点符合得非常好

但是,切换到webpack后,这只会在webpack中引发错误:

ERROR in ./src/somepath/test.ts
(..,..): error TS2503: Cannot find namespace 'TestController'.
在我看来,这似乎是typescript编译器与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
    }
}

请添加包含
ActivityController
+您的
webpack.config
的代码。另外,这是一个猜谜游戏:)你能同时包含你的tsconfig.json吗?@SebastianSebald activationcontroller是我用作示例的,刚刚将其重命名为TestController,所以它的代码类型大致相同。
webpack.config.js
也是一个简单的webpack配置文件,没有什么特别之处。但是,我附加了
tsconfig.json
,因为它可能是相关的。@olee当有人要求您显示某个内容时,您应该显示它。特别是,因为您在问题中说,您认为它与您的网页包配置有关:-/
{
    "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
    }
}