Skip to content

New option to detect unresolved components in template #5142

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

Closed
nickofthyme opened this issue Jan 22, 2025 · 1 comment
Closed

New option to detect unresolved components in template #5142

nickofthyme opened this issue Jan 22, 2025 · 1 comment

Comments

@nickofthyme
Copy link

What problem does this feature solve?

Coming back to vue after a long time in the react world, I setup a basic app with typescript and I found that vue/typescript ignores missing components from the <template>. Or more specifically does not detect unresolved components in the <template>.

For example take the file below...

<script setup lang="ts">
  import { RouterLink, RouterView } from 'vue-router'
  // import HelloWorld from './components/HelloWorld.vue'
</script>

<template>
  <header>
    <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />

    <div class="wrapper">
      <HelloWorld msg="You did it!" />

      <nav>
        <RouterLink to="/">Home</RouterLink>
        <RouterLink to="/about">About</RouterLink>
      </nav>
    </div>
  </header>

  <RouterView />
</template>

The HelloWorld component is used in the template but I commented out the import in the script. But VSCode shows no type error for the missing component, nor does vite complain during compilation. The app renders fine but the missing component is just rendered as a generic HTML element.

If I replace the import, I get full prop type checking.

What does the proposed solution look like?

I would like a new option in vueCompilerOptions to enforce PascalCase components in the <template> to be resolved.

See original discussion here #3479

@KazariEX
Copy link
Member

KazariEX commented Jan 23, 2025

See https://github.com/vuejs/language-tools/wiki/Vue-Compiler-Options#stricttemplates.

The checkUnknown* options will be released in the next version, you can use strictTemplates first.

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