question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extended diagnostics in compiler

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:18
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
dgp1130commented, 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!

1reaction
dgp1130commented, Oct 11, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extended Diagnostics - Angular Blog
Extended diagnostics are shown in both the compiler via ng build and ng serve as well as the Angular Language Service. They are...
Read more >
Expressive Diagnostics - Clang - LLVM
First, all diagnostics produced by clang include full column number information. The clang command-line compiler driver uses this information to print "point ...
Read more >
25.1.1. Compiler Diagnostics
25.1.1. Compiler Diagnostics · Conditions of type error may be signaled by the compiler in situations where the compilation cannot proceed without intervention....
Read more >
Localization of Compiler Diagnostic Messages - Swift Forums
Diagnostics play a vital role in a programming language experience. It's vital for developer productivity that the compiler can produce proper ...
Read more >
Compiler Diagnostic Options - Intel
Compiler Diagnostic Options. This section contains descriptions for compiler options that pertain to compiler diagnostics.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found