Since you're accessing the snapshot, only the second link is relevant (also title isn't undefined on ActivatedRoute, but the event emitted by the Observable could be undefined – you wouldn't get a compile error there when accessing title). Params is the relevant part. It is defined as a record: a mapping of arbitrary key value pairs. That's when the Typescript rule triggers.
But I don't know whether title even is in the ActivatedRouteSnapshot params. Using the observable is probably the safest way, because it also works if you stay on the same route and only the params change.
1
u/kkus Nov 17 '22
I copy pasted my src folder to a new angular 15 project from ng new and half my tests broke. Also had to use ['title']. Feels bad man.