What’s New in Angular 11?

Jessica
5 min readNov 20, 2020

Photo by Esteban Lopez on Unsplash.

Angular has just released version 11 of its remarkable framework, so let’s explore Angular’s latest features.

Component Test Harnesses

Component test harness allows tests to interact with components using supported APIs. This was first introduced in Angular 9. These APIs have the ability to interact with the components in a similar way to the end-users and tests can insulate themselves against the changes in the DOM.

At that time, this mechanism only supported Angular material. But with the latest release, a Component harness is available for all components.

The following example shows the usage of MatButtonHarness in Angular material:

https://www.ausy.fr/alex/ligue-1/P-v-M000.html

https://www.ausy.fr/alex/ligue-1/P-v-M001.html

https://www.ausy.fr/alex/ligue-1/P-v-M002.html

https://www.ausy.fr/alex/ligue-1/P-v-M003.html

https://www.ausy.fr/alex/ligue-1/P-v-M004.html

https://www.ausy.fr/alex/ligue-1/B-v-R000.html

https://www.ausy.fr/alex/ligue-1/B-v-R001.html

https://www.ausy.fr/alex/ligue-1/B-v-R002.html

https://www.ausy.fr/alex/ligue-1/B-v-R003.html

https://www.ausy.fr/alex/ligue-1/B-v-R004.html

https://carepropertyinvest.be/invest/ligue-1/B-v-R000.html

https://carepropertyinvest.be/invest/ligue-1/B-v-R001.html

https://carepropertyinvest.be/invest/ligue-1/B-v-R002.html

https://carepropertyinvest.be/invest/ligue-1/B-v-R003.html

https://carepropertyinvest.be/invest/ligue-1/B-v-R004.html

https://carepropertyinvest.be/invest/ligue-1/P-v-M000.html

https://carepropertyinvest.be/invest/ligue-1/P-v-M001.html

https://carepropertyinvest.be/invest/ligue-1/P-v-M002.html

https://carepropertyinvest.be/invest/ligue-1/P-v-M003.html

https://carepropertyinvest.be/invest/ligue-1/P-v-M004.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s01.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s02.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s03.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s04.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s05.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s06.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s07.html

https://www.ausy.fr/alex/ligue-1/Re-Bo-en-dir-tv-s08.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s01.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s02.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s03.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s04.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s05.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s06.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s07.html

https://carepropertyinvest.be/invest/ligue-1/Re-Bo-en-dir-tv-s08.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q00.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q01.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q02.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q03.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q04.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q05.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q06.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q07.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q08.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q09.html

https://www.ausy.fr/alex/ligue-1/Ren-Bor-w-w-w-Q10.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q00.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q01.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q02.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q03.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q04.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q05.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q06.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q07.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q08.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q09.html

https://carepropertyinvest.be/invest/Ren-Bor-w-w-w-Q10.html

Updated Hot Module Replacement (HMR) Support

Hot Module Replacement is a mechanism that allows modules to be replaced without a full browser refresh. HMR is not an entirely new thing to Angular and developers were able to use it with previous versions as well. But with Angular 11, the amount of effort you need to configure the HMR has been reduced drastically and they have provided a CLI command for that.

Now you can simply use the ng serve command with an hmr tag to enable HMR:

ng serve --hmr

TypeScript 4.0 Support

With this latest update, the Angular team has dropped support for TypeScript 3.9. Now Angular 11 only supports TypeScript 4.0.

One of the main reasons behind this upgrade is to speed up the builds. Angular 11 ensures much faster builds than previous versions.

Webpack 5 Support

As you know, webpack is used to compile a large number of files into a single bundle or single file. Webpack 5 is the latest version and was released in the last month. It is still not fully stable.

However, Angular 11 provides experimental support for webpack 5 and you can use it with Angular 11 to try out new things. According to the release notes, the Angular team believe that they can extend this experimental support to achieve faster builds and small bundles once things get stable.

If you are up to try webpack 5, you can start by adding the following lines to your package.json file:

“resolutions”: {
“webpack”: “5.4.0”
}

Moving to ESLint

TSLint was one of the most popular linting tools among developers for a long period of time. But it was recently deprecated and duties were handed to ESLint.

Angular is also moving from TSLint to ESLint with the version 11 update and you won’t be able to use TSLint for linting purposes in Angular again. Angular has introduced a three-step method to migrate from TSLint to ESLint.

1. Add relevant dependencies

ng add @angular-eslint/schematics

2. Run the convert-tslint-to-eslint schematic on a project

ng g @angular-eslint/schematics:convert-tslint-to-eslint {{YOUR_PROJECT_NAME_GOES_HERE}}

3. Remove root TSLint configuration and use only ESLint

Remove the root-level tslint.json.

You can find more details about migration from:

Updated Language Service Preview

“The Angular Language Service provides code editors with a way to get completions, errors, hints, and navigation inside Angular templates. It works with external templates in separate HTML files, and also with in-line templates.” — Angular’s documentation

Previously, this language service was based on View Engine. Angular 11 provides a new more powerful and accurate Ivy-based language service.

Although this feature is also still in development, it has the capability of behaving similarly to the TypeScript compiler.

Other Changes

Apart from that, Angular 11 brings a large number of small changes like:

  • New automated migrations and schematics.
  • Service worker improvements.
  • Lazy loading support for named outlets.
  • Angular CLI can now generate resolve guards.
  • Stricter types built in pipes.
  • The formatDate function now supports ISO 8601 week-numbering year format.

Some breaking changes

  • Angular 11 removes IE 9, 10, and IE mobile support completely.
  • TypeScript 3.9 is no longer supported.
  • preserveQueryParams has been removed in router and queryParamsHandling=”preserve” can be used instead.
  • Expressions within ICUs are now type-checked again.
  • The async pipe no longer claims to return undefined for an input that was typed as undefined.

Conclusion

I think you now have an understanding of some significant features of Angular 11. But these are only a subset of features provided by Angular 11 and you can find more details on their blog as well.

In the meantime, if you are willing to update your projects to Angular 11, you just need to run the following command:

ng update @angular/cli @angular/core

Thank you for reading!

Resources

Better Programming

Advice for programmers.

Follow

269

1

Thanks to Zack Shapiro.

--

--