Angular 9's Best Hidden Feature: Strict Template Checking

Great article as always :+1:

I am super happy about the strictTemplates improvement. :tada:
Detecting bugs in build time is preferable!

There is a TS issue tho when going all-in with strict configurations and trying to do the input type coercion. Angular has to mitigate it with ngAcceptInputType_* :man_facepalming:

TS Issue: Angular
Angular workaround: Angular (nice they thought about it)


Most common example of this is when using async pipe on an @Input of a component.
async pipe will always return T | null, which means if T is boolean, and your component accepts boolean, you will still get “not assignable” error due to the null from async - which is correct btw.

Normally you would then create a setter and getter for that input and coerce the type in a setter, but preserve the intended type of the input in getter, this however doesn’t work in TS (issue above).