angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.33k stars 6.73k forks source link

Enable --strictPropertyInitialization for library code #13329

Open jelbourn opened 6 years ago

jelbourn commented 6 years ago

We want to turn this on so that cdk/material don't have an exception inside Google (which has all strictness checks enabled).

rkirov commented 5 years ago

Ping on this, looks like there are still some failures. I can blast ! with an autofixer if you will prefer that?

jelbourn commented 5 years ago

@rkirov Kristiyan had a PR, but we deprioritized it over other stuff. How aggressively do you want to turn off this exception?

rkirov commented 5 years ago

It is not urgent, we were just cleaning up the special exceptions for not particular reason. We can wait another year.

rkirov commented 4 years ago

It's been close to an year and a lot of new code was written without checking for strict property initialization.

Since I had the auto-fixer ready (we used it internally years ago), I made a large PR suppressing errors and turning on the flag - https://github.com/angular/components/pull/19339.

My secret motivation here is to clean-up some of the special cases we have added internally when compiling angular2_material.

amakhrov commented 2 years ago

This also impacts external users of angular/material lib, not just lib authors internally.

Due to the lack of this check, some component optional inputs are incorrectly declared as non-nullable, which makes it harder to use in apps. Some examples I'm staring at right now are MatFormField#appearance (has a default fallback) and MatAutocompleteTrigger#matAutocompleteConnectedTo.

Pretty sure there are more examples like that

amakhrov commented 2 years ago

Related: https://github.com/angular/components/issues/21038