angular-update-guide icon indicating copy to clipboard operation
angular-update-guide copied to clipboard

Unclear instruction about router pathMatch in ver 13 => 14 upgrade guide

Open HarlanAtWork opened this issue 3 years ago • 0 comments

One of the upgrade notes about moving from Angular 13 to 14 reads "If you are defining routes with pathMatch, you may have to cast it to Route or Routes explicitly. Route.pathMatch is no longer compatible with string type." I may have to cast what?

The second sentence contradicts the interface declaration at https://angular.io/api/router/Route, which is:

pathMatch?: 'prefix' | 'full'

So, it's still a string type. How do you cast that to Route or Routes?

More specifically, if my existing definition of routes begins

const routes: Routes = [
  { path: '', pathMatch: 'full', component: HomeComponent },

then what is the upgrade note telling me I have to do? Maybe "it" in the note refers to the route, and I need to cast

{ path: '', pathMatch: 'full', component: HomeComponent }

to a Route, but what does that have to do with being "no longer compatible with a string type"?

HarlanAtWork avatar Jan 06 '23 21:01 HarlanAtWork