一切都在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) {}我尝试添加export、export declare和declare,但没有结果。
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"
]
}
}发布于 2021-08-24 10:39:26
我也遇到过类似的问题,升级Angular直到12岁,然后我收到了一堆“找不到命名空间”的错误消息。在我的例子中,更新更改了tsconfig.app.json文件,并使用以下部分对其进行了扩展:
"include": [
"src/**/*.d.ts"
]由于我的tsconfig.app.json文件已经位于src文件夹中,因此我需要将提到的部分修改为:
"include": [
"**/*.d.ts"
]这就解决了这个问题!
https://stackoverflow.com/questions/62647618
复制相似问题