forked from vuejs/language-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.vue
56 lines (49 loc) · 1.33 KB
/
main.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!-- @inferTemplateDollarSlots true -->
<template>
<!-- component slots type -->
<Comp value="1">
<template #foo="bindings">{{ exactType(bindings, {} as string) }}</template>
</Comp>
<Comp :value="1">
<template #foo="bindings">{{ exactType(bindings, {} as number) }}</template>
</Comp>
<!-- template slots type -->
<slot name="bar" str="str" :num="1"></slot>
<Self>
<template #bar="{ str, num }">
{{ exactType(str, {} as string) }}
{{ exactType(num, {} as number) }}
</template>
</Self>
<!-- typed slot key -->
<slot :name="baz" str="str" :num="1"></slot>
<Self>
<template #baz="{ str, num }">
{{ exactType(str, {} as string) }}
{{ exactType(num, {} as number) }}
</template>
</Self>
</template>
<script lang="ts">
export default {
name: 'Self',
slots: Object as SlotsType<{ foo?: (props: any) => any }>,
};
declare const Comp: new <T>(props: { value: T; }) => {
$props: typeof props;
$slots: {
foo: (props: T) => VNode[];
},
};
</script>
<script lang="ts" setup>
import { ref, type SlotsType, useSlots, type VNode } from 'vue';
import { exactType } from '../../shared';
const baz = ref('baz' as const);
const slots = useSlots();
exactType(slots, {} as {
readonly foo?: (props: any) => any;
bar?: (props: { str: string; num: number; }) => any;
baz?: (props: { str: string; num: number; }) => any;
});
</script>