8000 fix(language-core): infer parameter type of union slots to be union instead of intersection by KazariEX · Pull Request #5475 · vuejs/language-tools · GitHub
[go: up one dir, main page]

Skip to content
Dismiss alert

fix(language-core): infer parameter type of union slots to be union instead of intersection #5475

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

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

C 8000 onversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function generateGlobalTypes({
index: number,
][];
function __VLS_getSlotParameters<S, D extends S>(slot: S, decl?: D):
__VLS_PickNotAny<NonNullable<D>, (...args: any) => any> extends (...args: infer P) => any ? P : any[];
D extends (...args: infer P) => any ? P : any[];
function __VLS_asFunctionalDirective<T>(dir: T): T extends import('${lib}').ObjectDirective
? NonNullable<T['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>
: T extends (...args: any) => any
Expand Down
2 changes: 1 addition & 1 deletion
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function* generateSlotParameters(
nextStart = end;
}
yield chunk(nextStart, expression.equalsGreaterThanToken.pos - 1);
yield `] = __VLS_getSlotParameters(${slotVar}`;
yield `] = __VLS_getSlotParameters(${slotVar}!`;

if (types.some(t => t)) {
yield `, `;
Expand Down
19 changes: 19 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#5474/main.vue
< 5246 /tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script setup lang="ts">
import { exactType } from '../../shared';

type Foo = { foo: string };
type Bar = { bar: string };

declare const Comp: (props: {}, ctx: { slots: {
foo: (props: Foo) => void;
bar: (props: Bar) => void;
} }) => {};
</script>

<template>
<Comp>
<template v-for="name in (['foo', 'bar'] as const)" #[name]="props">
{{ exactType(props, {} as Foo | Bar) }}
</template>
</Comp>
</template>
0