-
-
Notifications
You must be signed in to change notification settings - Fork 465
feat(language-core): type support of slot children #5137
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
feat(language-core): type support of slot children #5137
Conversation
vue-component-meta
vue-component-type-helpers
@vue/language-core
@vue/language-plugin-pug
@vue/language-server
vue-tsc
@vue/language-service
@vue/typescript-plugin
commit: |
6201b84
to
c0df03a
Compare
5ae4b38
to
d782f70
Compare
β¦ feat/typed-slot-children
β¦ feat/typed-slot-children
β¦ feat/typed-slot-children
11e1997
to
d3b1c8a
Compare
Awesome!! |
If only text content is expected in a slot, how would one type that? I tried numerous things: const slots = defineSlots<{
default?: () => HTMLElement;
}>();
const slots = defineSlots<{
default?: () => Text;
}>();
const slots = defineSlots<{
default?: () => string;
}>(); I tried all of these separately, but text content in a slot is typed as const slots = defineSlots<{
default?: () => [];
}>(); |
We currently do not generate virtual code for text nodes, so this cannot be type checked yet. You can indeed use |
Hmm that's too bad, because even though this is a very very welcome addition, it's not entirely strict that way. See, you can do this without getting any TS errors:
|
After discussing with other members, we think that this feature is not yet perfect. We hope to eventually achieve an effect similar to |
Oh I see! So it's experimental? Will the syntax change in the future? Because in that case, probably good to mention that in the Wiki too. |
You are right. I'll consider making this feature experimental for now. |
Thanks, good idea. By the way, as an outsider, it was not very clear what every It also seems like the deepwiki is outdated about this topic: https://deepwiki.com/vuejs/language-tools/2.2-typescript-integration#vue-compiler-options |
I cannot find out how to suggest changes to the wiki or make a PR for it, so I created a discussion for it here: #5509 Note that I'm still working on it, but accidentally submitted the discussion already (π ), so I'll add more to it in the following hours. |
Resolves vuejs/rfcs#733