Does Scoped Slots support second parameter?
#14126
Unanswered
AuroraTea
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
From Vue's best practices, I understand that scoped slots should typically receive a single parameter (an object) containing all the properties. In standard Vue implementations, when attributes are added to a element, they become properties of this first parameter.
However, while using Arco Design Vue, I've noticed cases where a second parameter is provided to scoped slots, and it works as expected:
https://arco.design/vue/en-US/component/tree#icons
However, when using TypeScript, calling the second parameter itself or its properties will trigger errors because TypeScript doesn't recognize them as coming from a scoped slot. Such as:
Property 'props' does not exist on type '{ treeData: any; logProps: (props: any) => void; $: ComponentInternalInstance; $data: {}; $props: {}; $attrs: Data; $refs: Data; $slots: Readonly<InternalSlots>; ... 14 more ...; _pStores?: Record<...> | undefined; }'. Did you mean '$props'?ts-plugin(2551)runtime-core.d.ts(491, 5): '$props' is declared here.The fact that the second parameter works at runtime while TypeScript throws errors has made me deeply curious about whether this pattern is actually valid in Vue.
Of course, if this issue should only be discussed in Arco Design's repository, I'm happy to delete this discussion.
Beta Was this translation helpful? Give feedback.
All reactions