Prod Error at Angular Compiler

We get a very confusing error at prod build. They log says: Property 'date' is private and only accessible within class. We don't get this error on local machine. Has anyone an idea whats the problem?
1 answer

This one is the BEST answer!

This error appears because of the AOT-compiler.

There are two compilers in Angular:
JIT (Just-in-Time): It's for local machines and faster than AOT compiler, but special features like tree shaking are not enabled.
AOT(Ahead-of-Time): It's compiler used for prod builds. This compiler enables for example tree shaking, which takes more time during compiling but decreases loading time of the application by a lot.

And this AOT compiler doesn't allow private symbols because he can only interact with exported members. Decorated and data bound properties must be public.

Comments

This is a fairly simple and nice solution, you've pinpointed the error nicely and said what can be done to fix it. You also provided additional information and described the two compilers which is nice and helps the reader learn something that they would very likely have to learn later anyway.

Maybe it also would have been nice to include the information about how one can switch the compiler, since it is the first question that comes to mind when reading this answer and the reader would then have to get this information elsewhere.

Lastly a note for the Lecture Team, I rated your question with 3 stars (knowledgeable) with respect to its relevance, but Techscreen is showing my rating as if I had given you only 1 star. Clicking on 3 stars to change my rating, or clicking on the 1 star to cancel it does not seem to do anything for me. This may be a bug with Techscreen, but in any case please note my correct rating above.

Alem Zupa - Sun, 12/06/2020 - 20:03 :::