Skip to content

No option to ignore type-checking library components in node_modules #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
michumk opened this issue Jan 9, 2025 · 2 comments
Open

Comments

@michumk
Copy link

michumk commented Jan 9, 2025

Describe the bug
Currently, if we use use both nuxt-typed-router and @nuxt/content modules in the same project, the nuxt typecheck command results with an error

This happens because a component in @nuxtjs/mdc (a dependency of @nuxt/content) does not comply with rules enforced by nuxt-typed-router.

None of the nuxt-typed-router configuration options currently resolve the issue.

Expected behavior
A configuration option to disable type-checking internal components in node_modules, allowing libraries that don't comply with nuxt-typed-router rules to work without issues.

Error output

~/projects/nuxt-starter-iex3xpmq 22s
❯ npm run typecheck

> typecheck
> nuxt typecheck

node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseA.vue:2:4 - error TS2345: Argument of type '{ href: string; target: "_blank" | "_parent" | "_self" | "_top" | null | undefined; }' is not assignable to parameter of type 'Omit<NuxtLinkProps, "to" | "external"> & { to: any; external?: false | undefined; } & Record<string, unknown>'.
  Property 'to' is missing in type '{ href: string; target: "_blank" | "_parent" | "_self" | "_top" | null | undefined; }' but required in type '{ to: any; external?: false | undefined; }'.

2   <NuxtLink
     ~~~~~~~~

  .nuxt/typed-router/typed-router.d.ts:40:3
    40   to: NuxtRoute<T, P, E>;
         ~~
    'to' is declared here.


Found 1 error in node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseA.vue:2

Reproduction
https://stackblitz.com/edit/nuxt-starter-iex3xpmq?file=nuxt.config.ts

Steps to reproduce

  1. npm install
  2. npm run typecheck
@malkhuzayyim
Copy link

I ran into this today too. Any workarounds found?

@malkhuzayyim
Copy link

I ended up overriding the ProseA component in nuxt by grabbing their version and just adding ts-expect-error on NuxtLink there

this works fine:

<script setup lang="ts">
import type { PropType } from "vue";

const props = defineProps({
  href: {
    type: String,
    default: "",
  },
  target: {
    type: String as PropType<
      | "_blank"
      | "_parent"
      | "_self"
      | "_top"
      | (string & object)
      | null
      | undefined
    >,
    default: undefined,
    required: false,
  },
});
</script>

<template>
  <!-- @vue-expect-error -->
  <NuxtLink
    :href="props.href"
    :target="props.target"
  >
    <slot />
  </NuxtLink>
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants