In this post I will be listing down new features in Angular 11 version.
Angular 11 release date not yet finalized.
Update: Angular 11 version is released
Angular 11 features.
As part of Angular 11 version, Google Added so many new features to existing Angular packages. And few breaking changes from the past releases.
asyncfunction,In Angular 11 they have added a migration that finds all imports and calls to the
asyncfunction and replaces with
- In Angular 11, ViewEncapsulation does not have Native value. They are replacing it with ViewEncapsulation.ShadowDm. (ViewEncapsulation.Native=>ViewEncapsulation.ShadowDm)38882.
- Adding a schematic to update users to the new Angular 11 initialNavigation options for RouterModule. This replaces the deprecated/removed true, false, legacy_disabled, and legacy_enabled options with the newer enabledBlocking and enabledNonBlocking options.36926
- Introducing a Trusted Types policy that is only available in development mode, that allows arbitrary unsafe conversions to Trusted Types to support development features.This fixes a Trusted Types violation that occurs in
createNamedArrayTypeduring development mode. Instead of passing strings directly to “new Function”, use the Trusted Types compatible function constructor exposed by the Trusted Types development policy.39209
- create internal Trusted Types module (#39207) (0875fd2)
- depend on type definitions for Trusted Types (#39207) (c4266fb)
- remove ViewEncapsulation.Native (#38882) (4a1c12c)
- TemplateTypeChecker operation to get Symbol from a template node (#38618) (c4556db)
- Add ability to get Symbol of Templates and Elements in component template (#38618) (cf2e8b9)
- Add ability to get Symbol of AST expression in component template (#38618) (f56ece4)
- add ability to get symbol of reference or variable (#38618) (19598b4)
- define interfaces to be used for TemplateTypeChecker (#38618) (9e77bd3)
- support getting resource dependencies for a source file (#38048) (5dbf357)
- Add keySpan to Variable Node (#38965) (239968d)
- Parse and recover on incomplete opening HTML tags (#38681) (6ae3b68), closes #38596
- Add ISO week-numbering year formats support to formatDate (#38828) (984ed39)
- stricter types for DatePipe (#37447) (daf8b7f)
- stricter types for number pipes (#37447) (7b2aac9)
- Add getDefinitionAndBoundSpan (go to definition) (#39101) (3975dd9)
- add quick info for inline templates in ivy (#39060) (904adb7)
- [Ivy] getSemanticDiagnostics for external templates (#39065) (63624a2)
- Add getTypeDefinitionAtPosition (go to type definition) (#39145) (a84976f)
- Add module name to directive quick info (#39121) (4604fe9)
- add migration for AbstractControl.parent accesses (#39009) (aeec223), closes #32671
- add migration to update calls to navigateByUrl and createUrlTree with invalid parameters (#38825) (7849fdd), closes #38227
- Add relativeLinkResolution migration to update default value (#38698) (15ea811)
- add new initialNavigation options to replace legacy (#37480) (c4becca)
- add UnrecoverableStateError
- add the option to prefer network for navigation requests (#38565) (a206852), closes #38194
Angular 11 Breaking changes
- core: CollectionChangeRecord has been removed, use IterableChangeRecord instead
- forms: Previously if FormControl, FormGroup and FormArray class instances had async validators defined at initialization time, the status change event was not emitted once async validator completed. After this change the status event is emitted into the statusChanges observable. If your code relies on the old behavior, you can filter/ignore this additional status change event.
- router: This change corrects the argument order when calling RouteReuseStrategy#shouldReuseRoute. Previously, when evaluating child routes, they would be called with the future and current arguments would be swapped. If your RouteReuseStrategy relies specifically on only the future or current snapshot state, you may need to update the shouldReuseRoute implementation’s use of “future” and “current” ActivateRouteSnapshots.
- common: The locale data API has been marked as returning readonly arrays, rather than mutable arrays, since these arrays are shared across calls to the API. If you were mutating them (e.g. calling sort(), push(), splice(), etc) then your code will not longer compile. If you need to mutate the array, you should now take a copy (e.g. by calling slice()) and mutate the copy.
- common: When passing a date-time formatted string to the DatePipe in a format that contains fractions of a millisecond, the milliseconds will now always be rounded down rather than to the nearest millisecond. Most applications will not be affected by this change. If this is not the desired behaviour then consider pre-processing the string to round the millisecond part before passing it to the DatePipe.
- core: If you call TestBed.overrideProvider after TestBed initialization, provider overrides are not applied. This behavior is consistent with other override methods (such as TestBed.overrideDirective, etc) but they throw an error to indicate that, when the check was missing in the TestBed.overrideProvider function. Now calling TestBed.overrideProvider after TestBed initialization also triggers an error, thus there is a chance that some tests (where TestBed.overrideProvider is called after TestBed initialization) will start to fail and require updates to move TestBed.overrideProvider calls before TestBed initialization is completed.
- packaging: In v10, IE 9, 10, and IE mobile support was deprecated. In v11, Angular framework removes IE 9, 10, and IE mobile support completely. Supporting outdated browsers like these increases bundle size, code complexity, and test load, and also requires time and effort that could be spent on improvements to the framework. For example, fixing issues can be more difficult, as a straightforward fix for modern browsers could break old ones that have quirks due to not receiving updates from vendors.
- platform-webworker: @angular/platform-webworker and @angular/platform-webworker-dynamic have been removed as they were deprecated in v8
- common: The slice pipe now returns null for the undefined input value, which is consistent with the behavior of most pipes. If you rely on undefined being the result in that case, you now need to check for it explicitly.
- common: The typing of the keyvalue pipe has been fixed to report that for input objects that have number keys, the result will contain the string representation of the keys. This was already the case and the code has simply been updated to reflect this. Please update the consumers of the pipe output if they were relying on the incorrect types. Note that this does not affect use cases where the input values are Maps, so if you need to preserve numbers, this is an effective way.
- common: The signatures of the number pipes now explicitly state which types are accepted. This should only cause issues in corner cases, as any other values would result in runtime exceptions.
- common: The signature of the date pipe now explicitly states which types are accepted. This should only cause issues in corner cases, as any other values would result in runtime exceptions.
- common: The async pipe no longer claims to return undefined for an input that was typed as undefined. Note that the code actually returned null on undefined inputs. In the unlikely case you were relying on this, please fix the typing of the consumers of the pipe output.
- common: The case conversion pipes no longer let falsy values through. They now map both null and undefined to null and raise an exception on invalid input (0, false, NaN) just like most “common pipes”. If your code required falsy values to pass through, you need to handle them explicitly.
- router: While the new parameter types allow a variable of type NavigationExtras to be passed in, they will not allow object literals, as they may only specify known properties. They will also not accept types that do not have properties in common with the ones in the Pick. To fix this error, only specify properties from the NavigationExtras which are actually used in the respective function calls or use a type assertion on the object or variable: as NavigationExtras.
- router: This commit changes the default value of relativeLinkResolution from ‘legacy’ to ‘default’. If your application previously used the default by not specifying a value in the ExtraOptions and uses relative links when navigating from children of empty path routes, you will need to update your RouterModule to specifically specify ‘legacy’ for relativeLinkResolution. See https://angular.io/api/router/ExtraOptions#relativeLinkResolution for more details.