Single SPA共享Angular独立组件:导入类型错误问题求助
问题描述
搭建了Single SPA + 3个Angular应用的架构,其中一个Angular应用名为ui-kit,目标是导出其独立组件供另外两个应用共享。
在ui-kit应用的main.single-spa.ts中做了如下导出:
// main.single-spa.ts - Ui Kit app export * from './app/button/button.component';
在Angular App 1的app.component中导入ButtonComponent并添加到imports数组时,触发以下错误:
'imports' must be an array of components, directives, pipes, or NgModules. Value is of type '[RouterOutlet, undefined]'
奇怪的是,在ngOnInit中打印ButtonComponent能得到正确的Angular组件类,因此推测是类型定义问题。尝试了两种declarations.d.ts写法,但问题仍未解决:
第一种declarations.d.ts写法
declare module '@shared/ui-kit' { import { Type } from '@angular/core'; export const ButtonComponent: Type<any>; export function getData(data: string): string; }
第二种declarations.d.ts写法
declare module '@shared/ui-kit';
内容的提问来源于stack exchange,提问作者Matteo
相关产品推荐
相关产品推荐

