diff --git a/packages/language-core/lib/codegen/globalTypes.ts b/packages/language-core/lib/codegen/globalTypes.ts index 6e79d65730..c25ccbfc8f 100644 --- a/packages/language-core/lib/codegen/globalTypes.ts +++ b/packages/language-core/lib/codegen/globalTypes.ts @@ -145,7 +145,7 @@ export function generateGlobalTypes(options: VueCompilerOptions) { : T extends string ? [string, number][] : T extends any[] ? [T[number], number][] : T extends Iterable ? [V, number][] - : [T[keyof T], keyof T, number][]; + : [T[keyof T], \`\${keyof T}\`, number][]; function __VLS_vSlot(slot: S, decl?: D): D extends (...args: infer P) => any ? P : any[]; function __VLS_asFunctionalDirective(dir: T): T extends import('${lib}').ObjectDirective diff --git a/test-workspace/tsc/passedFixtures/vue3/v-for/main.vue b/test-workspace/tsc/passedFixtures/vue3/v-for/main.vue index beeca70391..a1f1b4ed8d 100644 --- a/test-workspace/tsc/passedFixtures/vue3/v-for/main.vue +++ b/test-workspace/tsc/passedFixtures/vue3/v-for/main.vue @@ -37,10 +37,22 @@ {{ exactType(key, {} as string) }} {{ exactType(index, {} as number) }} + +
+ {{ exactType(val, {} as string) }} + {{ exactType(key, {} as '1' | '2' | '3') }} + {{ exactType(index, {} as number) }} +
+ +
+ {{ exactType(val, {} as string) }} + {{ exactType(key, {} as 'a' | 'b') }} + {{ exactType(index, {} as number) }} +
{{ exactType(val, {} as any) }} - {{ exactType(index, {} as string | number | symbol) }} + {{ exactType(index, {} as string | number) }}
@@ -52,5 +64,7 @@ const map = new Map(); const obj = { a: '', b: 0 }; const objUnion = { a: '' } as { a: string } | { a: string, b: number }; const record: Record = { a: '' }; +const recordNumberKey: Record<1 | 2 | 3, string> = { 1: '', 2: '', 3: '' }; +const recordUnionKey: Record<'a' | 'b', string> = { 'a': '', 'b': '' }; const _any = {} as any;