8000 feat(jsx-directive)!: use v-slots instead of vSlots (#930) · vue-macros/vue-macros@21fd970 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21fd970

Browse files
authored
feat(jsx-directive)!: use v-slots instead of vSlots (#930)
* feat(jsx-directive)!: use v-slots instead of vSlots * fix: test
1 parent 42968b3 commit 21fd970

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

packages/jsx-directive/src/core/v-slot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function transformVSlot(
2727
Array.from(nodeMap)
2828
.reverse()
2929
.forEach(([node, { attributeMap, vSlotAttribute }]) => {
30-
const result = [` vSlots={{`]
30+
const result = [` v-slots={{`]
3131
const attributes = Array.from(attributeMap)
3232
attributes.forEach(
3333
([attribute, { children, vIfAttribute, vForAttribute }], index) => {

packages/jsx-directive/tests/__snapshots__/v-slot.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Comp: FunctionalComponent<
1616
}
1717
> = (props, { slots }) => {
1818
return (
19-
<Child vSlots={{...Object.fromEntries(__MACROS_renderList(slots, (Slot, slotName) => ([[__MACROS_unref(slotName)], (scope) => <>
19+
<Child v-slots={{...Object.fromEntries(__MACROS_renderList(slots, (Slot, slotName) => ([[__MACROS_unref(slotName)], (scope) => <>
2020
<Slot {...scope} />
2121
</>,]))),}}
2222
@@ -28,25 +28,25 @@ let baz = $ref('')
2828
let show = $ref<boolean | undefined>()
2929
defineRender(() => (
3030
<div>
31-
<Child vSlots={{'bottom': ({ foo }) => <>
31+
<Child v-slots={{'bottom': ({ foo }) => <>
3232
{foo}
33-
<Child vSlots={{'default': () => <>default</>,}}></Child>
33+
<Child v-slots={{'default': () => <>default</>,}}></Child>
3434
</>,}}></Child>
3535
36-
<Comp vSlots={{'default': () => <>default</>,}}></Comp>
37-
<Child vSlots={{'bottom': ({ foo }) => <>{foo}</>,}}></Child>
36+
<Comp v-slots={{'default': () => <>default</>,}}></Comp>
37+
<Child v-slots={{'bottom': ({ foo }) => <>{foo}</>,}}></Child>
3838
39-
<Child baz={baz} vSlots={{'title': ({ foo }) => <>
39+
<Child baz={baz} v-slots={{'title': ({ foo }) => <>
4040
{expectTypeOf<string>(foo)}
4141
</>,}}></Child>
4242
43-
<Child vSlots={{...(show) ? {'bottom': ({ foo }) => <>
43+
<Child v-slots={{...(show) ? {'bottom': ({ foo }) => <>
4444
{foo}
4545
</>,} : null,}}
4646
4747
></Child>
4848
49-
<Child<number> vSlots={{...(show) ? {'title': ({ foo }) => <>
49+
<Child<number> v-slots={{...(show) ? {'title': ({ foo }) => <>
5050
{expectTypeOf<number>(foo)}
5151
{show}
5252
</>,} : (show === false) ? {'center': ({ foo }) => <>

packages/volar/src/jsx-directive/context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export function resolveCtxMap(
1818
): Map<import('typescript').Node, string> {
1919
if (ctxNodeMap.size) {
2020
options.codes.push(`
21-
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
22-
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
21+
// @ts-ignore
22+
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
2323
type __VLS_Element = globalThis.JSX.Element;
24-
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
24+
declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
2525
T extends new (...args: any) => any
2626
? (props: (K extends { $props: infer Props } ? Props : any) & Record<string, unknown>, ctx?: any) => __VLS_Element & { __ctx?: {
2727
attrs?: any,
@@ -35,7 +35,7 @@ const __VLS_nativeElements = {
3535
...{} as SVGElementTagNameMap,
3636
...{} as HTMLElementTagNameMap,
3737
};
38-
function __VLS_getFunctionalComponentCtx<T, K, const S>(
38+
declare function __VLS_getFunctionalComponentCtx<T, K, const S>(
3939
comp: T,
4040
compInstance: K,
4141
s: S,
@@ -46,7 +46,7 @@ function __VLS_getFunctionalComponentCtx<T, K, const S>(
4646
? Ctx
4747
: never
4848
: T extends (props: infer P, ctx: infer Ctx) => any
49-
? { props: P; slots: P['vSlots']; expose: P['vExpose'] } & Ctx
49+
? { props: P } & Ctx
5050
: {};\n`)
5151
}
5252

packages/volar/src/jsx-directive/v-slot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function transformVSlot(
2828
const { codes, ts, ast, source, prefix } = options
2929

3030
nodeMap.forEach(({ attributeMap, vSlotAttribute }, node) => {
31-
const result: Code[] = [' vSlots={{']
31+
const result: Code[] = [' v-slots={{']
3232
const attributes = Array.from(attributeMap)
3333
attributes.forEach(
3434
([attribute, { children, vIfAttribute, vForAttribute }], index) => {

0 commit comments

Comments
 (0)
0