Skip to content
Advertisement

How to create new Flow type having all properties of existing type but optional

I have a type State in which all fields are required:

JavaScript

I need to create a new type with all properties the same as in State but not required:

JavaScript

How can I implement this similarly to the following Flow pseudocode?

JavaScript

Advertisement

Answer

You can use $Shape utility:

JavaScript

$Shape Copies the shape of the type supplied, but marks every field optional.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement