• Vue <script setup> compiler macro for declaring component props. The expected argument is the same as the component props option.

    Example runtime declaration:

    // using Array syntax
    const props = defineProps(['foo', 'bar'])
    // using Object syntax
    const props = defineProps({
    foo: String,
    bar: {
    type: Number,
    required: true
    }
    })

    Equivalent type-based declaration:

    // will be compiled into equivalent runtime declarations
    const props = defineProps<{
    foo?: string
    bar: number
    }>()

    Type Parameters

    • PropNames extends string = string

    Parameters

    Returns Prettify<Readonly<{
        [key in PropNames]?: any
    }>>

    https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits

    This is only usable inside <script setup>, is compiled away in the output and should not be actually called at runtime.

  • Type Parameters

    Parameters

    Returns Prettify<Readonly<ExtractPropTypes<PP>>>

  • Type Parameters

    • TypeProps

    Returns DefineProps<LooseRequired<TypeProps>, BooleanKey<TypeProps>>