Repository navigation
Description
Which @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
Activity
dgp1130 commentedon Jul 26, 2021
/cc @alxhub @atscott.
refactor(compiler-cli): add makeTemplateDiagnostic wrapper
refactor(compiler-cli): add makeTemplateDiagnostic wrapper (#42937)
refactor(compiler-cli): add makeTemplateDiagnostic wrapper (#42937)
angular-robot commentedon Jul 27, 2021
This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.
You can find more details about the feature request process in our documentation.
itea-dev commentedon Jul 27, 2021
@eneajaho @ahnpnl
A suggestion for you... Use thumbs up (👍) for voting.
296 remaining items
angular-robot commentedon Sep 5, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
dgp1130 commentedon Sep 9, 2021
Most of the implementation here is done (thanks @danieltre23!). We're current working through some of the surrounding integrations that need to be done. The three main tasks left before we can do an initial MVP release are:
Some initial ideas of additional checks we could add:
i18nattribute.foo?.baris useless iffoois not nullable.foo | date: "format" ?? 'test'??applies to"format", which isn't what the user wanted.We'll need to decide how much to do for the initial release and what we want to defer for later.
dgp1130 commentedon Sep 10, 2021
Some more possible ideas: #42690
angular-robot commentedon Sep 25, 2021
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
dgp1130 commentedon Sep 27, 2021
Just discussed the configuration support we'll need for MVP. Our current plan is to support:
This will be managed in the
tsconfig.jsonso editors, language service, and the like will see and use these options. The Angular CLI already supports compiling with a specifictsconfig.jsonin the browser builder, so users could create multiple targets with different configurations if they want to be more specific (such as warnings in local dev but errors on CI).This should be enough for an MVP of the feature that can be officially launched. I also have #43582 out to make
ngc-wrappedpass the build if only warnings are emitted, as well as #43572 to fix a minor bug in the nullish coalescing not nullable check. We'll also need to confirm that the CLI doesn't fail when given only warnings, but that should be an easy fix if not.Tracking google3 launch of this feature in http://b/199443160.
angular-robot commentedon Sep 28, 2021
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
dgp1130 commentedon Oct 11, 2021
One more idea for an extended template diagnostic, warn on
!=or==in an*ngIfconditional. 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.dgp1130 commentedon Dec 7, 2021
#44391 has the main implementation of the configuration. Once that lands a simple flag flip should be sufficient to enable the feature.
The one other task left to do is make some documentation on the implemented diagnostics. Long term, we'd like to make something similar to https://angular.io/errors. For now, we'll start with just a single page that talks about these diagnostics and lists out the two we're starting with (
invalidBananaInBoxandnullishCoalescingNotNullable), how they work, why they are bad practice, and what users can do about them.JoostK commentedon Jan 27, 2022
This is now available in 13.2, for anyone interested here's the docs.
dgp1130 commentedon Jan 28, 2022
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!
==/!=in templates #44872DaSchTour commentedon Feb 1, 2022
I wonder what is the difference between diagnostics checks and @angular-eslint/eslint-plugin-template? I think it would be better to have one solution and not create different in worst case incompatible solutions.
Linter would also have the benefit of beeing visible while without angular runing and also having fixers.
dgp1130 commentedon Feb 2, 2022
@DaSchTour, see #44712 (comment) for a bit more background.
Extended diagnostics are intended to work with
angular-eslintand provide a hook for surfacing critical diagnostics to the user earlier to save debugging and implementation time. Linters offer a much broader set of checks than extended diagnostics are intended to support.To address your two specific comments, extended diagnostics are visible in the Angular language service and should appear in your IDE. I also just opened an issue about supporting fixers (#44941), which is something we experimented with a while back and are hoping to implement in the future.
angular-automatic-lock-bot commentedon Mar 5, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.