How to set a props type with InputHTMLAttributes? #7546
-
| For example, having a custom input component, when using it I want to have full autocompletion with all input props that are already defined by  The example below (with an expected error) illustrates what I'm trying to achieve here: <script lang="ts" setup>
import { InputHTMLAttributes } from "vue";
const props = defineProps<InputHTMLAttributes>();
const emit = defineEmits<{ (e: "input", value: string): void }>();
</script>
<template>
  <div>
    <input
      type="text"
      v-bind="props"
      @input="(e) => emit('input', (e.target as HTMLInputElement).value)"
    />
    />
  </div>
</template>Then using it: <InputSearch :value="input" @input="(value) => (input= value)" placeholder="Search here..." /> | 
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
| see #4294 | 
Beta Was this translation helpful? Give feedback.
-
| Related to vuejs/rfcs#477 | 
Beta Was this translation helpful? Give feedback.
-
| So this should work now using Vue 3.3, correct? When I try exactly this syntax using Vue 3.3 I get an error  However if I do destructured assignment ( This workaround worked for me (still not pretty, but at least I can use it the way I want) @lucas-santosP have you tried this since the release of Vue 3.3? | 
Beta Was this translation helpful? Give feedback.
see #4294