1- import { registerApplication , mountRootParcel } from "single-spa" ;
1+ import { Application , AppProps , ParcelConfigObject } from "single-spa" ;
22import { chooseDomElementGetter } from "dom-element-getter-helpers" ;
33import { ApplicationConfig , Type } from "@angular/core" ;
44
5- type CustomProps = Parameters < typeof mountRootParcel > [ 1 ] ;
6- type Application < Props extends CustomProps > = Extract <
7- Parameters < typeof registerApplication < Props > > [ 1 ] ,
8- { bootstrap }
9- > ;
10- type LifecycleFn < Props extends CustomProps > = Extract <
11- Application < Props > [ "bootstrap" ] ,
12- ( config : any ) => Promise < any >
13- > ;
14- export type AppProps < Props extends CustomProps > = Parameters <
15- LifecycleFn < Props >
16- > [ 0 ] ;
17-
18- export function singleSpaAngular < Props extends CustomProps > (
5+ export function singleSpaAngular < Props > (
196 opts : SingleSpaAngularOpts < Props > ,
20- ) : Application < Props > {
7+ ) : Application < Props > | ParcelConfigObject < Props > {
218 let applicationRef : Destroyable | null = null ;
229 let selectorElement : HTMLElement | null = null ;
2310 const selector = opts . selector ?? opts . rootComponent [ "ɵcmp" ] ?. selectors ?. [ 0 ] ;
24- let currentProps : AppProps < Props > | null = null ;
11+ let currentProps = null ;
2512
2613 if ( ! selector ) {
2714 throw Error (
@@ -30,10 +17,10 @@ export function singleSpaAngular<Props extends CustomProps>(
3017 }
3118
3219 return {
33- async bootstrap ( props : AppProps < Props > ) {
20+ async bootstrap ( props : AppProps & Props ) {
3421 currentProps = props ;
3522 } ,
36- async mount ( props : AppProps < Props > ) {
23+ async mount ( props : AppProps & Props ) {
3724 const domElement = chooseDomElementGetter ( opts , props ) ( ) ;
3825 selectorElement = document . createElement ( selector ) ;
3926 domElement . appendChild ( selectorElement ) ;
@@ -46,10 +33,10 @@ export function singleSpaAngular<Props extends CustomProps>(
4633 opts . appConfig ,
4734 ) ;
4835 } ,
49- async update ( props : AppProps < Props > ) {
36+ async update ( props : AppProps & Props ) {
5037 currentProps = props ;
5138 } ,
52- async unmount ( props : AppProps < Props > ) {
39+ async unmount ( props : AppProps & Props ) {
5340 currentProps = props ;
5441 await applicationRef ! . destroy ( ) ;
5542 applicationRef = null ;
0 commit comments