Strange JIT/AOT compiler behavior with static boolean flag

Hi all,

We found an issue: depending on if compiling with ionic cordova build or ionic cordova build --prod --release, a ternary conditional operator considers the condition flag to be always true, being that flag an static member of a Typescript class.

For example:

File app.config.ts:

export class AppConfig {
    public static readonly IS_COMPONENT_FLAG = false;

File app.module.ts:

  imports: [
      IonicModule.forRoot(AppConfig.IS_COMPONENT_FLAG ? AppComponentTrue : AppComponentFalse)
export class AppModule { }

When the previous code is run with ionic serve or ionic cordova run, the AppComponentTrue component is displayed. Nevertheless when run with ionic cordova run --prod --release, the AppComponentFalse component is displayed.

In this S.O. question there’s a simple project you can download to reproduce it.

Does anybody have an explanation for this? Is it an Ionic / Angular AOT compiler bug?

Thanks in advance.