Skip to content

Upgrading @angular/platform-browser-dynamic 17 to 18

Breaking17.3.12 → 18.2.14Breaking47Security1Platform2Deprecated10New40Changed4Fixed234Other6

BreakingUpgrade verdict

37 breaking changes and 2 platform requirement changes and a security fix.

  • Server-side apps now receive a bootstrap context object instead of relying on a shared global platform, and platform helpers behave differently on the server.
  • On the server, the global platform is no longer used, so getting it returns nothing and destroying it does nothing.
  • Tests using fakeAsync will now automatically run any timers left pending when the test function finishes.
  • A deprecated animation helper method has been removed, so code calling it will no longer work.
Top 5 of 50 that need code or config changes

Node.js requirement changed in 18.1.0-next.1: ^18.13.0 || >=20.9.0 → ^18.19.1 || ^20.11.1 || >=22.0.0.

Breaking37
Introduces BootstrapContext for server bootstrapping, removing reliance on a global platform injector.
BootstrapContextbootstrapApplication
Server-side bootstrapping no longer relies on a global platform injector; getPlatform() returns null and destroyPlatform() is a no-op on the server.
getPlatform()destroyPlatform()
fakeAsync now flushes pending timers at the end of the given function by default.
fakeAsync
Removes deprecated matchesElement from AnimationDriver.
AnimationDrivermatchesElement
Removes deprecated isPlatformWorkerApp and isPlatformWorkerUi APIs.
isPlatformWorkerAppisPlatformWorkerUi
Removes support for unassignable expressions in two-way bindings.
Removes deprecated transfer state APIs.
StateKeyTransferStatemakeStateKey
Removes deprecated Testability methods.
Testability
Removes the unused RESOURCE_CACHE_PROVIDER API.
RESOURCE_CACHE_PROVIDER
Removes the deprecated platformDynamicServer API.
platformDynamicServer
Removes the deprecated ServerTransferStateModule API.
ServerTransferStateModule
Removes deprecated useAbsoluteUrl and baseUrl from PlatformConfig; provide an absolute url instead.
useAbsoluteUrlbaseUrlPlatformConfigurl
Removes legacy URL handling logic.
ComponentFixture autoDetect no longer refreshes OnPush host views that are not marked dirty.
ComponentFixtureautoDetectOnPushmarkForCheckChangeDetectionStrategy.Default
Removes Testability methods increasePendingRequestCount, decreasePendingRequestCount and getPendingRequestCount.
increasePendingRequestCountdecreasePendingRequestCountgetPendingRequestCount
HTTP transfer cache now prevents caching of requests requiring authorization by default.
withHttpTransferCacheincludeRequestsWithAuthHeaders
Removes deprecated StateKey, TransferState and makeStateKey from @angular/platform-browser; use @angular/core instead.
StateKeyTransferStatemakeStateKey
Removes the unused RESOURCE_CACHE_PROVIDER APIs from @angular/platform-browser-dynamic.
RESOURCE_CACHE_PROVIDER
Removes deprecated platformDynamicServer; import @angular/compiler and use platformServer instead.
platformDynamicServerplatformServer
Removes deprecated ServerTransferStateModule; TransferState can be used without providing this module.
ServerTransferStateModuleTransferState
Removes legacy Node.js URL parsing from ServerPlatformLocation, changing pathname and port handling.
ServerPlatformLocation
Excludes authenticated HTTP requests from caching by default; opt out with includeRequestsWithAuthHeaders in withHttpTransferCache.
withHttpTransferCacheincludeRequestsWithAuthHeaders
Angular now ensures change detection runs even when state updates originate outside the zone.
provideZoneChangeDetection({schedulingMode: NgZoneSchedulingMode.NgZoneOnly})TestBedbootstrapApplicationBootstrapOptionsbootstrapModule
ComponentFixture.whenStable now matches ApplicationRef.isStable, including unfinished router navigations and HttpClient requests.
ComponentFixture.whenStableApplicationRef.isStableHttpTestingController.verify()ComponentFixture.isStable
Modifies EventType from an enum to an object.
EventType
Angular only supports writable expressions inside of two-way bindings.
OnPush root views must be marked dirty for host bindings to refresh.
OnPush
Change detection now refreshes views still marked for check after a round, which can surface NG0103 infinite loop errors.
ApplicationRefChangeDetectorRef.detectChangesNG0103
Removes the async test helper; use waitForAsync instead.
asyncwaitForAsync
Change detection timing with event or run coalescing in NgZone is now the first of setTimeout or requestAnimationFrame.
NgZonesetTimeoutrequestAnimationFrameafterNextRender
Newly created or reattached views marked for check are now guaranteed to refresh in the same change detection cycle.
ExpressionChangedAfterItHasBeenCheckedError
Guards can now return RedirectCommand for redirects in addition to UrlTree.
RedirectCommandUrlTreeRoute
Allows Route.redirectTo to be a function in addition to a string, so code expecting only a string must be adjusted.
Route.redirectToRoute
Guard redirects via UrlTree now use replaceUrl when the initial navigation used replaceUrl; use RedirectCommand to override.
UrlTreereplaceUrlNavigationBehaviorOptionsRedirectCommand
Routed components now always get providers from the route injector hierarchy and never inherit from the RouterOutlet.
RouterOutletNgModuleproviders
Completes the removal of the deprecated async function; use waitForAsync instead.
asyncwaitForAsync
ComponentFixture.autoDetect now runs change detection within ApplicationRef.tick, changing refresh order in tests.
ComponentFixture.autoDetectApplicationRef.tick
Security1
Addresses Trusted Types violations in @angular/upgrade.
@angular/upgrade
Platform2
Drops support for TypeScript versions older than 5.4.
Angular no longer supports TypeScript versions older than 5.4.
Deprecated10
Deprecates the ignoreChangesOutsideZone option.
ignoreChangesOutsideZone
Adds back the phase flag option as a deprecated API.
Deprecates Local Data API functions.
Deprecates @Component.interpolation.
@Component.interpolation
Deprecates HttpClientModule and related modules.
HttpClientModule
Deprecates the getLocale* and getCurrencySymbol locale data functions in common.
getCurrencySymbolgetLocaleCurrencyCodegetLocaleCurrencyNamegetLocaleCurrencySymbolgetLocaleDateFormatgetLocaleDateTimeFormatgetLocaleDayNamesgetLocaleDayPeriods
Deprecates @Component.interpolation in favor of Angular's delimiters.
@Component.interpolation
Deprecates HttpClientModule, HttpClientXsrfModule and HttpClientJsonpModule, which can be replaced by provider functions.
HttpClientModuleHttpClientXsrfModuleHttpClientJsonpModule
Deprecates @Component.interpolation in favor of Angular's delimiters.
@Component.interpolation
Deprecates HttpClientModule and related modules in favor of provider functions.
HttpClientModuleHttpClientXsrfModuleHttpClientJsonpModule

Generated by DepDelta from published .d.ts files. Not mixed with prose notes.

  • removed: const RESOURCE_CACHE_PROVIDER: Provider[]
  • changed: const platformBrowserDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef → const platformBrowserDynamic: (extraProviders?: StaticProvider[]) => PlatformRef
  • changed: const ɵplatformCoreDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef → const ɵplatformCoreDynamic: (extraProviders?: StaticProvider[]) => PlatformRef
  • changed: const platformBrowserDynamicTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef → const platformBrowserDynamicTesting: (extraProviders?: StaticProvider[]) => PlatformRef