In this guide, we’ll break down the new features and the walk through any breaking changes that may affect your current code.
New features in Angular 10
The following features were introduced with the latest Angular release.
CommonJS import warnings
CommonJS was originally designed for server-side modules, not to reduce the production bundle size. Using dependencies packaged with CommonJS can result in larger code bundles and slower applications.
Angular version 10 now warns you when your build pulls in a CommonJS module.
Angular in strict mode
In version 10, you can set up new projects with stricter settings using the
ng new --strict
These optional settings help improve maintainability, catch bugs ahead of time, and allow the Angular CLI to perform advanced optimizations on your app.
strict flag does the following.
- Enables strict mode in TypeScript
- Turns template type checking to
- Reduces default bundle budgets by as much as 75 perceng
- Configures linting rules to prevent declarations of type
- Configures your app as side-effect free to enable more advanced tree-shaking
Updated browser support
Angular 10 discontinued support for older and less popular browsers, such as IE abd UC browsers. It also disabled ES5 builds for new projects.
If you still want support for older browsers, simply add them to the
Below is an overview of notable breaking changes associated with Angular 10.
New TypeScript version
TypeScript is one of the major dependencies of the Angular framework. Angular 10 comes with support for Typescript 3.9. Typescript 3.8 and Typescript 3.7 are no longer supported.
Other dependencies, such as TSLib and TSLint, were also updated to versions 2 and 6, respectively.
In addition, to better support the way IDEs and build tools resolve type and package configurations, the Angular team added a new TypeScript configuration file called
Improvement on input field of type
Prior to version 10, input fields of type
number fired the
valueChanges event twice: the first time after typing in the input field and the second time when the input field loses the focus.
In this new version, input fields of type
number fire the
valueChanges event only once per value change.
maxLength form validators
Previously, the behavior of the
maxLength form validators caused confusion, making it appear as though they work with numeric values. These validators now verify that a value has a numeric
length property and invoke validation only if that’s the case.
Unknown properties and elements error
Templates with unknown property bindings or element names now log errors instead of warnings. This won’t break your app, but it may trip up tools that expect nothing to be logged via
UrlMatcher now returns
UrlMatchResult, which is the return type for
UrlMatcher, now supports
Navigation cancellation for at least one
When a route that has a single resolver resolves with an empty observables (no next, only complete, as in
EmptyObservable), navigation is canceled.
For multiple resolver routes, empty observables are treated differently than with a single resolver. If, for example, one of two resolvers resolves to an empty observable, the navigation is not canceled, but the corresponding route-data field is undefined as a result.
This is no longer the case in Angular version 10. If at least one resolver resolves with an empty observable, navigation is canceled.
Updating to Angular 10
To update to Angular 10:
ng update @angular/cli @angular/core
Consult the Angular Update Guide for detailed information on installing Angular 10.
You come here a lot! We hope you enjoy the LogRocket blog. Could you fill out a survey about what you want us to write about?
Experience your Angular apps exactly how a user doesDebugging Angular applications can be difficult, especially when users experience issues that are difficult to reproduce. If you’re interested in monitoring and tracking Angular state and actions for all of your users in production, try LogRocket. https://logrocket.com/signup/
The LogRocket NgRx plugin logs Angular state and actions to the LogRocket console, giving you context around what led to an error, and what state the application was in when an issue occurred.
Modernize how you debug your Angular apps - Start monitoring for free.