Search code examples
angularnativescriptnativescript-schematics

Why is NO_ERRORS_SCHEMA so frequently used by nativescript?


I noticed that NO_ERRORS_SCHEMA is frequently used by nativescript modules both by the nativescript-schematics but also in examples by nativescript with Angular. However I'm just wondering why that is the case?

I guess there is a good explanation for this, I'm just not that into nativescript yet. Normally I would say using NO_ERRORS_SCHEMA should be avoided as it makes your debugging a lot harder so I'm very curious about why this is used everywhere.

Examples:

https://docs.nativescript.org/performance-optimizations/lazy-loading

https://github.com/NativeScript/nativescript-schematics/blob/master/src/generate/module/index.ts#L327

https://github.com/NativeScript/nativescript-schematics/blob/master/src/generate/module/index_spec.ts#L72


Solution

  • NativeScript elements like StackLayout, GridLayout, ListView etc., are not known to Angular. So it will throw compiler error unless you include NO_ERRORS_SCHEMA.

    But of course as you mentioned already, it might make debugging difficult. Once you specify NO_ERRORS_SCHEMA, the app will silently fail for any invalid elements.