Skip to content

Commit

Permalink
fix(language-core): @ts-ignore not working for slots
Browse files Browse the repository at this point in the history
close #4263
  • Loading branch information
johnsoncodehk committed Apr 12, 2024
1 parent 69281f2 commit 65774a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/language-core/lib/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,6 @@ export function* generate(
}
const slotBlockVars: string[] = [];
yield _ts(`{\n`);
yield* resetDirectiveComments('end of element slot start');
let hasProps = false;
if (slotDir?.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {

Expand Down Expand Up @@ -868,6 +867,8 @@ export function* generate(
localVars.set(varName, (localVars.get(varName) ?? 0) + 1);
});

yield* resetDirectiveComments('end of slot children start');

let prev: CompilerDOM.TemplateChildNode | undefined;
for (const childNode of node.children) {
yield* generateAstNode(childNode, parentEl, prev, componentCtxVar);
Expand Down
26 changes: 26 additions & 0 deletions test-workspace/tsc/vue3/#4263/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<SomeComponent some-prop>
<!-- @vue-ignore -->
<template #item="{ item: itemSlot }">
<slot name="item" :item="(itemSlot as any)"></slot>
</template>
</SomeComponent>

<!-- @vue-ignore -->
<SomeComponent some-prop #item="{ item: itemSlot }">
<slot name="item" :item="(itemSlot as any)"></slot>
</SomeComponent>

<!-- @vue-ignore -->
<SomeComponent some-prop #item="{ item: itemSlot }"></SomeComponent>
<!-- @vue-expect-error -->
<SomeComponent some-prop #item="{ item: itemSlot }"></SomeComponent>
</template>

<script setup lang="ts">
declare const SomeComponent: new () => {
$slots: {
item(props: {}): any;
};
};
</script>

0 comments on commit 65774a6

Please sign in to comment.