Extended diagnostics in compiler
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
compiler-cli
Description
The compiler should have some capability for “extended template diagnostics”, meaning diagnostics applied after type checking. Currently, the compiler doesn’t really have any warnings, and only ever fails for fatal issues that directly prevent compilation (with some minor exceptions). These extended diagnostics will allow warnings to be easily authored to check for smaller mistakes like getting two-way binding syntax backwards ([foo])="bar"
or having extraneous operators like using foo ?? 'bar'
when foo
is not nullable.
For scoping, we just need a private flag in the compiler for now. This will be enough for the CLI and language service to plug in and surface these diagnostics.
Proposed solution
A new private flag in the compiler which enables “extended template diagnostic” checks that give warning/information diagnostics about user templates which aren’t strictly fatal errors. This issue is mostly about building the required infrastructure, but we should include one or two simple checks to validate the system.
Alternatives considered
N/A
Issue Analytics
- State:
- Created 2 years ago
- Reactions:18
- Comments:16 (14 by maintainers)
Top GitHub Comments
I opened a few issues for some of the ideas we’ve had about future extended diagnostics. Please upvote any of these features if you’d like to see them in a future version of Angular!
One more idea for an extended template diagnostic, warn on
!=
or==
in an*ngIf
conditional. Devs should almost always prefer!==
or===
due to simpler behavior on type mismatches, and related lint checks for JS/TS code is pretty common. Doing the same for extended template diagnostics would be an easy win.