Reading through a javascript codebase, I encounter a block of code that looks like
export type RouteReducerProps = {|
error?: Error,
isResolving: boolean,
isResolved: boolean,
hasFailed: boolean,
|};
This looks like a javascript object literal definition, but I've never seen a javascript object literal with vertical bars inside the curly braces. What do those do?
This syntax is specific to Flow, a static type checker for javascript. It defines an Exact Object Type, which is an object for which a only a few specified keys are valid. In the example above, only the keys 'error?', 'isResolving', 'isResolved', and 'hasFailed' can be defined on the object RouteReducerProps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With