Great article as always
I am super happy about the strictTemplates improvement.
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_*
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).