Skip to content

dgp1130/Angular-Extended-Diagnostics-Demo

Repository files navigation

Angular Extended Diagnostics Demo

This is a demo of Angular extended diagnostics. In v13.2, Angular added extended diagnostics which flag possible mistakes in Angular templates as warnings. The app.component.ts file demos the two diagnostics introduced in 13.2 (invalid banana in box and nullish coalescing not nullable).

A VSCode editor open to an Angular template. The code editor raises two warnings within the template which the developer quickly fixes. The code gists which raise the errors is here: https://github.com/dgp1130/Angular-Extended-Diagnostics-Demo/blob/c6be7909cb6d52294154c7c7ad3fc38a1ad7e64a/src/app/app.component.ts#L5-L13

These diagnostics are warnings by default but can be configured in the tsconfig.json.

Angular configurations can be combined with extended diagnostics to present multiple build types with different strictness. A developer build could treat all diagnostics as informational warnings to avoid impeding the edit/refresh workflow while a continuous integration (CI) build could treat all diagnostics as hard errors. This is done in this repository with the ci configuration.

# Developer builds, extended diagnostics are warnings.
ng serve
ng build -c development

# Build for CI, extended diagnostics are errors.
ng build -c ci

This is implemented by defining a custom ci configuration in angular.json which uses tsconfig.ci.json and sets all extended diagnostics to errors.

"ci": {
"tsConfig": "tsconfig.ci.json"
}

"extendedDiagnostics": {
"defaultCategory": "error"
}

Fore more information about extended diagnostics, check out the Angular blog post on the topic!

About

A demo of Angular extended diagnostics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published