Skip to content

[Question] How to let TypeScript know that I've passed modelValue? #436

Open
@wenfangdu

Description

@wenfangdu

Child.tsx

import { defineComponent } from 'vue'

export default defineComponent({
  props: {
    modelValue: {
      type: Number,
      // 👇 required
      required: true,
    },
  },
  setup() {
    return () => <div>Child</div>
  },
})

Parent.tsx

import Child from '@/views/Child'
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const number = ref(0)
    //                  👇 I've used `v-model` to pass `modelValue`
    //                  but TypeScript is complaining that I didn't
    return () => <Child v-model={number.value} />
  },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions