Skip to content

Allow ExtractPropTypes to make props with default values optional #3122

Open
@kiroushi

Description

@kiroushi

Version

3.0.5

Reproduction link

https://codesandbox.io/s/stoic-hamilton-t8cft?file=/src/index.ts

Steps to reproduce

Access props via setup() block or use ExtractPropTypes utility to check props type inference (reproduction link has a naive example).

image

What is expected?

Props with a default property configured shouldn’t be marked as required by TS.

Edit: Seems like maybe I misunderstood the purpose of said utility. ExtractPropTypes is giving type safety to props argument, but not for objects that are safe to be bound to components with such properties.

Maybe there should be another utility that yield proper types from the binding perspective (as in, marking props with default properties as optional).

What is actually happening?

RequiredKeys<> TS utility is marking props that have default property as required (even if they are explicitly configured with required: false).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions