[英]Cannot find namespace after updating to Angular 10
Everything was working on Angular 8, I started updating first to Angular v9, then to Angular v10, and when I tried to run my project, all namespaces were affected, I hope maybe there is a solution to this issue instead of moving everything to an isolated Interface, I leave all the details below.一切都在 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:错误:
error TS2503: Cannot find namespace 'Auth'. login(credentials: Auth.Login) {}
I tried adding export
and export declare
and declare
but no results.我尝试添加
export
和export declare
并declare
但没有结果。
tsconfig.base.json 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"
]
}
}
I had a similar issue, upgraded Angular up until 12. Then I got a bunch of "Cannot find namespace" error messages.我有一个类似的问题,将 Angular 升级到 12。然后我收到一堆“找不到命名空间”错误消息。 In my case, the update changed the
tsconfig.app.json
file, and extended it with the following part:就我而言,更新更改了
tsconfig.app.json
文件,并使用以下部分对其进行了扩展:
"include": [
"src/**/*.d.ts"
]
Since my tsconfig.app.json
file was located already in the src
folder I needed to modify the mentioned part to become:由于我的
tsconfig.app.json
文件已经位于src
文件夹中,因此我需要将上述部分修改为:
"include": [
"**/*.d.ts"
]
And this resolved the issue!这解决了这个问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.