Closed brandonroberts closed 1 year ago
Thoughts on defining RouteMeta
type like this?
Differences compared to the original Angular Route
interface:
canLoad
property.Route
interface we can pass any[]
).Route
.Looks reasonable to be. Should we not extend/override the Angular Route
instead of recreating the route type for DefaultRouteMeta
?
Looks reasonable to be. Should we not extend/override the Angular
Route
instead of recreating the route type forDefaultRouteMeta
?
@brandonroberts We can define DefaultRouteMeta
like this and override only weakly typed route props:
type OmittedRouteProps =
| 'path'
| 'pathMatch'
| 'matcher'
| 'redirectTo'
| 'component'
| 'loadComponent'
| 'children'
| 'loadChildren'
| 'canLoad'
| 'outlet';
interface DefaultRouteMeta extends Omit<Route, OmittedRouteProps> {
canActivate?: CanActivateFn[];
canActivateChild?: CanActivateChildFn[];
canDeactivate?: CanDeactivateFn<unknown>[];
canMatch?: CanMatchFn[];
resolve?: { [key: string | symbol]: ResolveFn<unknown> };
title?: string | ResolveFn<string>;
}
interface RedirectRouteMeta {
redirectTo: string;
pathMatch?: Route['pathMatch'];
}
export type RouteMeta =
// enforce exclusive union
| (DefaultRouteMeta & { redirectTo?: never })
| RedirectRouteMeta;
👍
Which scope/s are relevant/related to the feature request?
router
Information
The
defineRouteMeta
function causes issues when eagerly loading files using glob imports with Vite. The function is only used to enforce the type for restricting what can be provided as route metadata.Proposed
Before:
After:
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue