I have encountered a problem with using TypeScript map in my Angular application. When I run the application using 'ng serve', everything works fine. However, if I use 'ng serve --aot', the maps are not functioning as expected. Despite not receiving any exceptions, the maps appear to be null during debugging. I would like to know if this is a known issue and if there is a workaround available. Thank you for your assistance.
//myLibrary
export class MyModule {
static forRoot(config: MyConfig ): ModuleWithProviders {
return {
ngModule: MyModule,
providers: [
{provide: MY_CONFIG, useValue: config}
]
}
}
}
export class MyConfig {
myArray? : string[];
myMap?: Map<string, string[]>;
}
//user application
export const testMap: Map<string, string[]> = new Map<string, string[]>();
testMap.set("key1", ["value1", "value2"]);
testMap.set("key2", ["value3", "value4"]);
@NgModule({
declarations: [
// some code
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
HttpClientModule,
MyModule.forRoot({
myArray: ["1234"],
myMap: testMap,
}
),
],
providers: [
],
bootstrap: [AppComponent]
})
export class AppModule {
}