[Vuejs]-How do you type vue-router meta attribute to be required?

0👍

It’s not a good practice to modify global behaviour for local purposes. Routes array can have custom type that fits the expectations. E.g. for routes with mandatory name and meta it’s something like:

interface RouteCommonMeta {
  ...
}

interface RouteCommonDef {
  name: RouteRecordName;
  meta: IRouteCommonMeta;
  children?: RouteDef[];
}

export type RouteDef = RouteRecordRaw & RouteCommonDefinition;


const routes: RouteDef[] = [...];

Leave a comment