question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typeerror with v-bind="$props"

See original GitHub issue

A.vue

<script lang="ts">

import {defineComponent, PropType} from "vue";

export default defineComponent({
	name: "A",
	props: {
		x: {
			type: Boolean as PropType<boolean>,
			default: false
		}
	}
});
</script>

<template>{props}</template>

B.vue

<script lang="ts">

import {defineComponent, PropType} from "vue";

import A from "./A.vue";

export default defineComponent({
	name: "B",
	components: {A},
	props: {
		x: {
			type: Boolean as PropType<boolean>,
			default: false
		}
	}
});
</script>

<template>
	<A
		v-bind="$props"
	/>
</template>

Error starting from 0.27.27

src/repro/B.vue:20:3 - error TS2322: Type '{ x?: boolean | undefined; ref?: VNodeRef | undefined; key?: string | number | symbol | undefined; onVnodeBeforeMount?: VNodeMountHook | VNodeMountHook[] | undefined; ... 6 more ...; style?: unknown; }' is not assignable to type 'IntrinsicAttributes & Partial<{ x: boolean; }> & Omit<Readonly<{ x?: unknown; } & { x: boolean; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, "x">'.
  Type '{ x?: boolean | undefined; ref?: VNodeRef | undefined; key?: string | number | symbol | undefined; onVnodeBeforeMount?: VNodeMountHook | VNodeMountHook[] | undefined; ... 6 more ...; style?: unknown; }' is not assignable to type 'IntrinsicAttributes'.
    Types of property 'ref' are incompatible.
      Type 'VNodeRef | undefined' is not assignable to type 'string | Ref<any> | ((ref: Element | ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null) => void) | undefined'.

20  <A
     ~

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
johnsoncodehkcommented, Oct 5, 2021

@pikax please cc, it seem that VNodeProps.ref type incompatible to ReservedProps.ref.

螢幕截圖 2021-10-05 上午10 55 43

@MoonCoral you can use v-bind="{ ...$props, ref: undefined }" instead of v-bind="$props" for now.

0reactions
henribrucommented, Oct 8, 2021

It seems like it works if you pass props through setup (e.g. setup(props) { return {props} }) and do v-bind="props". Is it intentional that props and $props have different types? Are they different at runtime?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug Report][3.0.0-alpha.11] Dialog throws errors ... - GitHub
0-alpha.11] Dialog throws errors when clicking on it - Uncaught TypeError: Cannot read property 'contains' of undefined #14101.
Read more >
javascript - Trigger components methods when click elsewhere
I've a HeaderSubmenu component which can show/hide a drop-down menu if a button is clicked. Okay, but now I try to find a...
Read more >
[Solved]-Attempt to fetch Objects returns Uncaught TypeError
Coding example for the question Attempt to fetch Objects returns Uncaught TypeError: Object function ParsePromise()-Vue.js.
Read more >
Error using structure field in k-form - Questions - Kirby forum
Writing on my first panel field extension I reached a point where I want to use a structure field inside the k-form component....
Read more >
Vue 3, vue-router and typescript - Vue Forum
I am using Vue 3, router and typescript. Webpack is reporting a type error on the router-view component. TS7031: Binding element 'Component' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found