Closed as duplicate of#520
Description
Vue - Official extension or vue-tsc version
V3beta4
VSCode version
1.101.2
Vue version
3.5.17
TypeScript version
5.8.3
System Info
System: OS: Windows 10 10.0.19045 CPU: (12) x64 AMD Ryzen 5 5600 6-Core Processor Memory: 24.65 GB / 31.89 GB Binaries: Node: 22.16.0 - ~\AppData\Local\fnm_multishells\5536_1750938671774\node.EXE npm: 10.9.2 - ~\AppData\Local\fnm_multishells\5536_1750938671774\npm.CMD pnpm: 10.11.1 - ~\AppData\Local\fnm_multishells\5536_1750938671774\pnpm.CMD Browsers: Edge: Chromium (127.0.2651.98) Internet Explorer: 11.0.19041.5794
package.json dependencies
Steps to reproduce
<template> <ul class="relative flex jusitify-center items-center list-none"> <li v-for="(item, index) in data" ref="lis" :key="item[value as K] as PropertyKey" :class="[ 'flex jusitify-center items-center h-8 px-2 z-10 leading-none', curValue[value as K]===item[value as K] && 'text-white' ]" @click="onClick(item, index)" > <input class="hidden" type="radio" :name="name" :value="item[value as K]" :checked="curValue[value as K]===item[value as K]" /> <label class="cursor-pointer"> {{ item[label] }} </label> </li> <li ref="slider" class="absolute left-0 top-1/2 rounded bg-primary transform-[translateY(-50%)] transition-all duration-300 ease-in-out" /> </ul> </template> <script setup lang="ts" generic="T extends Record<string,unknown>,K extends keyof T" > interface Props { data: Array<T> isObject?: boolean label?: string value?: K modelValue?: Partial<T> | T[K] prefix?: string } defineOptions({ name: 'MxSegment' }) const props = withDefaults(defineProps<Readonly<Props>>(), { isObject: () => false, label: () => 'label', value: () => 'value' as K, prefix: () => 'mx' }) const emit = defineEmits<{ (type: 'update:modelValue', arg: Props['modelValue']) }>() const curValue = computed<Partial<T>, Partial<T>>({ get() { return props.isObject ? props.modelValue || {} : ({ [props.value as K]: props.modelValue } as Partial<T>) }, set(value) { const _ = props.isObject ? value : value[props.value as K] emit('update:modelValue', _) } }) const name = `${props.prefix}-${useId()}` const lis = ref<Array<HTMLLIElement>>() const slider = ref<HTMLLIElement>() function calcPosition(i: number) { if (i >= 0) { const liItem = lis.value![i] slider.value!.setAttribute( 'style', `width:${liItem.offsetWidth}px;height:${liItem.offsetHeight}px;left:${liItem.offsetLeft}px;` ) } } function onClick(value: Partial<T>, i: number) { curValue.value = value nextTick(() => { calcPosition(i) }) } onMounted(() => { const i = props.data.findIndex( item => item[props.value] === (curValue.value as T)[props.value as K] ) calcPosition(i) }) </script>
What is expected?
works normal
What is actually happening?
syntax highlighting errors in vue files
Link to minimal reproduction
No response
Any additional comments?
No response