[英]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) {}
我嘗試添加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"
]
}
}
我有一個類似的問題,將 Angular 升級到 12。然后我收到一堆“找不到命名空間”錯誤消息。 就我而言,更新更改了tsconfig.app.json
文件,並使用以下部分對其進行了擴展:
"include": [
"src/**/*.d.ts"
]
由於我的tsconfig.app.json
文件已經位於src
文件夾中,因此我需要將上述部分修改為:
"include": [
"**/*.d.ts"
]
這解決了這個問題!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.