Angular 角度库项目生成在多项目工作区中失败-找不到命名空间

Angular 角度库项目生成在多项目工作区中失败-找不到命名空间,angular,typescript,typescript-typings,multi-project,Angular,Typescript,Typescript Typings,Multi Project,我有以下角度多项目文件结构: -AngularMultiProject -projects -mobile-app -shared-lib -web-app -ViewModels -Common -myviewmodel1.d.ts -myviewmodel2.d.ts declare module Common { export interface MyAVM { id: nu

我有以下角度多项目文件结构:

-AngularMultiProject
  -projects
     -mobile-app
     -shared-lib
     -web-app
  -ViewModels
     -Common
        -myviewmodel1.d.ts
        -myviewmodel2.d.ts
declare module Common {
    export  interface MyAVM {
            id: number;
            name:string;
        }

    export interface MyBVM {
        ...
    }
}

declare module CommonB {
    export  interface MyCVM {
            id: number;
            name:string;
        }

    export interface MyDVM {
        ...
    }
}
共享库项目和web app项目正在引用应用程序根文件夹中的viewmodels我可以构建web应用程序项目,但不能构建共享库项目。我得到以下错误:

EROR:…component.ts:12:27-错误TS2503:找不到命名空间“Common”

两个项目的typescript配置相同:

AngularMultiProject/tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "module": "esnext",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    //"downlevelIteration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom",
      "es2019"
    ],
    "paths": {
      "shared": [
        "dist/shared/shared",
        "dist/shared"
      ]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}
共享lib/tsconfig.lib.json和web app/tsconfig.lib.json

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "types": []
  }, 
  "include": [
    "src/**/*.d.ts",
    "../../ViewModels/**/*.d.ts"
  ]
}

经过长时间的反复试验,我发现:

您必须将包含所有模块/接口定义的.ts文件放入每个angular project文件夹中,并从库/项目的至少一个模块文件中引用它

.ts文件必须具有以下结构:

-AngularMultiProject
  -projects
     -mobile-app
     -shared-lib
     -web-app
  -ViewModels
     -Common
        -myviewmodel1.d.ts
        -myviewmodel2.d.ts
declare module Common {
    export  interface MyAVM {
            id: number;
            name:string;
        }

    export interface MyBVM {
        ...
    }
}

declare module CommonB {
    export  interface MyCVM {
            id: number;
            name:string;
        }

    export interface MyDVM {
        ...
    }
}
您必须至少从一个模块文件引用此文件,如下所示:

/// <reference path="../viewmodels.ts" />
}