router
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:
// src/app/routes/index.ts
import { defineRouteMeta } from '@analogjs/router';
export const routeMeta = defineRouteMeta({
title: 'Home',
});
After:
// src/app/routes/index.ts
import { RouteMeta } from '@analogjs/router';
export const routeMeta: RouteMeta = {
title: 'Home',
};
No response
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 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;
Owner Name | analogjs |
Repo Name | analog |
Full Name | analogjs/analog |
Language | TypeScript |
Created Date | 2022-07-06 |
Updated Date | 2023-03-28 |
Star Count | 885 |
Watcher Count | 18 |
Fork Count | 67 |
Issue Count | 33 |
Issue Title | Created Date | Updated Date |
---|