Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49355

Strange JIT/AOT compiler behavior with static boolean flag

$
0
0

@rbarriuso wrote:

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:

@NgModule({
  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.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49355

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>