Subscribe on changes!

props type tips

avatar
Jun 25th 2023

What problem does this feature solve?

cant get props type tips in custome type component A

<template>
  {{ type }}
</template>

<script setup lang='ts'>
import { defineProps } from 'vue'

defineProps({
  type: {
    default: 'success',
    validator(value: string) {
      return ['success', 'error', 'warn'].includes(value)
    }
  }
})
</script>
<A type='success'></A>

when i use the component, props 'type' has not type prompt.

What does the proposed API look like?

defineProps

avatar
Jun 26th 2023

Can you provide more information, I did not reproduce your problem. see

avatar
Jun 26th 2023

em... I mean when i use this component and enter 'type="success"', i cant get TypeScript syntax hints. But in this compoent, i had set the type of 'type' with 'success' or 'error' or 'warn'.

avatar
Jun 27th 2023

Duplicate of #8152

avatar
Jun 27th 2023

oh~, i thought that with a validator there would be type hints, so forgot to define the type of TypeScript, thx 🌷