79540161

Date: 2025-03-27 22:43:35
Score: 1
Natty:
Report link

The simplest solution to this problem I have found is manually importing the modified type and type casting the data to it.

So in this case I want to pass in the to.meta from my Nuxt middleware into the typed function. tsserver and vue-tsc are both telling me that to.meta is of the vue-router type RouteMeta which has been modified in my index.d.ts. So i adjusted my middleware to look like this:

import type { RouteMeta } from "vue-router";

// global authorization middleware that runs on every route to check if user is entitled to be there
export default defineNuxtRouteMiddleware(
  (to) => {
    // ...

    const isAuthorizedTo = useAuthStore().isAuthorizedTo(to.meta as RouteMeta);

    // ...
  },
);

I am typecasting from RouteMeta to RouteMeta, which feels redundant and unnecessary, but it does solve the compilation and language server issues.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: sam whittle