-
-
Notifications
You must be signed in to change notification settings - Fork 437
Property does not exist on type '[{ type: PropType<T>; required: true; }] #3267
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
Comments
This is a vue core type issue :( |
I had a similar issue that I posted here on StackOverflow My temporary solution was <li
v-for="(item, i) in items"
:key="
//@ts-ignore
item[itemKey]
"
> UPDATE: For posterity, several solutions were offered in the answer I got on Stack Overflow. The simplest seems to be just converting the key to a string which is one of the three allowed types ( <li
v-for="(item, i) in items"
:key="String(item[itemKey])"
> However, there are more in-depth solutions that involve type narrowing as well. |
I'm also having this issue. <template>
<label :class="[{ active: value?.key === target.key}]">foo</label>
<!-- ~~~ Property 'key' does not exist on type '[{ type: PropType<Target>; required: true; }] extends [Prop<infer V, infer D>] ? unknown extends V ? IfAny<V, V, D> : V : { type: PropType<Target>; required: true; }'.ts(2339) -->
</template>
<script setup lang="ts" generic="Target extends { key: string }">
defineProps<{ target: Target; value?: Target }>()
</script> The type checking works correctly within the script block. I can work around this issue by adding a computed ref which returns the key property for the value & target props. <template>
<label :class="[{ active: valKey === targetKey}]">foo</label>
</template>
<script setup lang="ts" generic="Target extends { key: string }">
import { computed } from 'vue';
const props = defineProps<{ target: Target; value?: Target }>()
const valKey = computed(() => props.value?.key)
const targetKey = computed(() => props.target.key)
</script> |
I've got this issue as well, it seems only to apply though when you use the prop directly via macro. Minimal reproduction with workaround:
|
Duplicate of #3820 |
Please track in #3820. |
… @ `<PostBadgeCommon>` $ git checkout 2567a86^1 src/components/post/badge/{Common,Time}.vue # to fix vuejs/language-tools#4820 + type `PostID` to reuse union `Tid | Pid | Spid` * rename the original type `PostID` to `PostIDStr` @ index.ts * rename prop `selector` to `el` in the returned value of `postListItemScrollPosition()` for matching with type `RouterScrollBehavior`, partial revert fec399a @ post/renderer/list/scroll.ts @ utils @ fe
This is a continuation of another issue where I bundled a few issues together which I probably shouldn't have done because it makes it hard to track.
I once again would like to offer my reproduction of this issue: https://github.com/Ragura/vue-issue-repro
The reproduction includes 3 components, of which 2 are important to this issue:
DropdownDestructuring
andDropdownTraditional
.Both components show the error:
Property 'id' does not exist on type '[{ type: PropType<T>; required: true; }] extends [Prop<infer V, infer D>] ? unknown extends V ? IfAny<V, V, D> : V : { type: PropType<T>; required: true; }'.
Code that shows the error looks like this:
For the
options
prop, the id of each array item is being recognized, even though it also originates fromT
.I am using the following:
vue-tsc: 1.7.11
vue: 3.3.4
Vue Language Features extension version 1.7.11, running takeover mode pointed to local
vue-tsc
typescript version 5.0.4.Using VSCode insiders.
The text was updated successfully, but these errors were encountered: