Repository: angular
Issue: Better typings for router package
Labels: feature,area: router,cross-cutting: types,feature: under consideration

# 🚀 feature request

### Relevant Package
`@angular/router`

### Description
I'd want propose better typing for routes. I've summarized it all below:

[**`ExtraOptions`**](https://angular.io/api/router/ExtraOptions):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| preloadingStrategy | any | Type\<PreloadingStrategy> | A more concrete type than `any`.

[**`ActivatedRoute`**](https://angular.io/api/router/ActivatedRoute)/[**`ActivatedRouteSnapshot`**](https://angular.io/api/router/ActivatedRouteSnapshot):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| component | Type\<any> \| string \| null | Type\<unknown> \| null | `component` cannot be a string.

[**`Route`**](https://angular.io/api/router/Route):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| canActivate | any[] | readonly (string \| Type\<CanActivate>)[] | It should accept only string or (readonly, optionally) array of classes.
| canActivateChild | any[] | readonly (string \| Type\<CanActivateChild>)[] | It should accept only string or (readonly, optionally) array of classes.
| canDeactivate | any[] | readonly (string \| Type\<CanDeactivate>)[] | It should accept only string or (readonly, optionally) array of classes.
| canLoad | any[] | readonly (string \| Type\<CanLoad>)[] | It should accept only string or (readonly, optionally) array of classes.

[**`Router`**](https://angular.io/api/router/Router):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| createUrlTree | any[] | readonly (boolean \| number \| string \| Record<'outlets', Record<string, readonly string[]>>)[] <sub>correct if I'm missing any accepted type here</sub> | it should accept only correct types. Also, it should accept readonly arrays.
| navigate | any[] | readonly (boolean \| number \| string \| Record<'outlets', Record<string, readonly string[]>>)[] <sub>correct if I'm missing any accepted type here</sub> | It should accept only correct types. Also, it should accept readonly arrays.

[**`RouterLink`**](https://angular.io/api/router/RouterLink)/[**`RouterLinkWithHref`**](https://angular.io/api/router/RouterLinkWithHref):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| routerLink | string \| any[] | string \| readonly (boolean \| number \| string \| Record<'outlets', Record<string, readonly string[]>>)[] <sub>correct if I'm missing any accepted type here</sub> | It should accept only correct types. Also, it should accept readonly arrays.

[**`RouterLinkActive`**](https://angular.io/api/router/RouterLinkActive):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| routerLinkActive | string \| string[] | string \| readonly string[] | It should accept readonly arrays.

[**`RouterOutlet`**](https://angular.io/api/router/RouterOutlet):
| Member | Current type | Proposed type | Reason
|-|-|-|-
| activate | EventEmitter\<any> | EventEmitter\<ComponentRef\<unknown>> | A more concrete type than `any`.
| deactivate | EventEmitter\<any> | EventEmitter\< ComponentRef\<unknown>> | A more concrete type than `any`.
| component | Object | ComponentRef\<unknown> | A more concrete type than `Object`.

[**`provideRoutes`**](https://angular.io/api/router/provideRoutes):
The return type should be `ValueProvider` instead of `any`.

<hr>

**Questions**:

- Why [**`Data`**](https://angular.io/api/router/Data) and [**`Navigation`**](https://angular.io/api/router/Navigation) are types instead of interfaces?
- What about creating a type to not duplicate the accepted type of `routerLink` and `Router#functions`?
- Could `RouterOutlet` accept an optional generic argument to avoid explicit `any`?
- About immutability, do you have any pretension to make non-mutable properties like `queryParams`, `queryParamMap`, `params` and `paramMap` `readonly`?