Skip to content

Commit

Permalink
fix(language-core): should wrap item with Reactive on v-for (#4902)
Browse files Browse the repository at this point in the history
Co-authored-by: Johnson Chu <johnsoncodehk@gmail.com>
  • Loading branch information
KazariEX and johnsoncodehk authored Oct 26, 2024
1 parent e6e8ae5 commit 8c1672f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion packages/language-core/lib/codegen/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
function __VLS_getVForSourceType(source: number): [number, number, number][];
function __VLS_getVForSourceType(source: string): [string, number, number][];
function __VLS_getVForSourceType<T extends any[]>(source: T): [
item: T[number],
item: ${(
target >= 3 ? `import('${lib}').Reactive<T[number]>` :
target >= 2.7 ? `import('${lib}').UnwrapNestedRefs<T[number]>` :
`T[number]`
)},
key: number,
index: number,
][];
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/tests/__snapshots__/dts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare const _default: <Row extends BaseRow>(__VLS_props: NonNullable<Awaited<t
attrs: any;
slots: {
default?(_: {
row: Row;
row: import("vue").Reactive<Row>;
}): any;
};
emit: {};
Expand Down
10 changes: 5 additions & 5 deletions test-workspace/tsc/passedFixtures/vue3/#3204/main.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup lang="ts" generic="T">
<script setup lang="ts" generic="T extends { foo: number }">
import { exactType } from '../../shared';
const props = withDefaults(defineProps<{
Expand All @@ -11,12 +11,12 @@ const props = withDefaults(defineProps<{

<template>
<div v-for="item of list">
{{ exactType(item, {} as T) }}
{{ exactType(item.foo, {} as number) }}
</div>
<div v-for="item of props.list">
{{ exactType(item, {} as T) }}
{{ exactType(item.foo, {} as number) }}
</div>
<div v-for="item of $props.list">
{{ exactType(item, {} as T) }}
{{ exactType(item.foo, {} as number) }}
</div>
</templat>
</template>

0 comments on commit 8c1672f

Please sign in to comment.