Can't make type check for props work for global components with volar
See original GitHub issueHi! I’ve created a fresh vite app with this plugin, added globalComponentsDeclaration: true
.
The file components.d.ts
is generated, but vscode doesn’t show me warnings of incorrect using of props, unless I import the component.
Button.vue:
<script setup lang="ts">
import { defineProps } from 'vue'
const props = defineProps({
size: {
type: String,
required: true,
},
})
</script>
Component is not imported (no type checks for props)
Component is imported, so type check works great.
I’m expecting to see something like that: https://twitter.com/antfu7/status/1397168229005463563 but can’t figure out what’s wrong.
And what’s more strange, this feature is working perfectly if I install a new vitesse project.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
cannot correctly infer type for $slots of global components #953
This is expected behavior, $slots type is from DefineComponent but not define by volar. You can not inherit parent slots type by this...
Read more >How can I make Volar aware of globally available components ...
Global components should be declared in src/components.d.ts : import { CAlert } from '@coreui/vue' declare module '@vue/runtime-core' ...
Read more >Using Vue with TypeScript - Vue.js
If using SFCs, use the vue-tsc utility for command line type checking and type ... To get Vue SFCs and TypeScript working together,...
Read more >volar/vue-typescript - NPM Package Versions - Socket.dev
Start using Socket to analyze @volar/vue-typescript and its 3 ... fix: props type checking not working for Element Plus components (#2176) (#2180) ...
Read more >Vue with TSX - the perfect duo!? - Arek Nawo
It's a (mostly) TS-only library of types, casting function, utilities, etc., meant to properly type your Vue components and make them work ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@antfu found the issue: By default vite have tsconfig.json:
So file
components.d.ts
is not included. Vitesse in the other hand doesn’t haveinclude
, onlyexclude
in the config.Probably it makes sense to add it to readme, so other people won’t get confused.
Yes, plugin is on. I will try to compare libraries between this and vitesse, probably some package is messing with type definitions. https://user-images.githubusercontent.com/347044/120286326-68a2b300-c2be-11eb-8639-eab9dc08501a.mov