Thanks to visit codestin.com
Credit goes to github.com

Skip to content

use 'declare' define prop? #962

@ghost

Description

Clear and concise description of the problem

exportProps problem

Suggested solution

declare global {
    type Prop<T, Default extends T | undefined = undefined> = Default extends T ? T : (T | undefined)
}

/** with default **/
declare let modelValue: Prop<number, 0>

/** that prop is required: false **/
declare const show: Prop<boolean>

/** that prop is required: true **/
declare const title: string

const inc = () => {
    modelValue += 1
}

/** expose */
export const dec = () => {
    modelValue -= 1
}

/** render **/
export default () => <div title={title} onClick={inc}>{modelValue}</div>

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions