繁体   English   中英

更新到 Angular 10 后找不到命名空间

[英]Cannot find namespace after updating to Angular 10

一切都在 Angular 8 上工作,我首先开始更新到 Angular v9,然后到 Angular v10,当我试图运行我的项目时,所有命名空间的解决方案都会受到影响,隔离接口,我将所有细节留在下面。

namespace Auth {
  export interface Token {
    access_token: string;
    token_type: string;
    expires_in: number;
    refresh_token: string;
    scope: string;
  }

  export interface Login {
    email: string;
    password: string;
    app_code?: number;
  }
}

错误:

error TS2503: Cannot find namespace 'Auth'. login(credentials: Auth.Login) {}

我尝试添加exportexport declaredeclare但没有结果。

tsconfig.base.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "downlevelIteration": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2018",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

我有一个类似的问题,将 Angular 升级到 12。然后我收到一堆“找不到命名空间”错误消息。 就我而言,更新更改了tsconfig.app.json文件,并使用以下部分对其进行了扩展:

 "include": [
    "src/**/*.d.ts"
  ]

由于我的tsconfig.app.json文件已经位于src文件夹中,因此我需要将上述部分修改为:

"include": [
   "**/*.d.ts"
]

这解决了这个问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM