How to specify an empty object in Flow type?
Try using $Shape<T>
to specify an object with no properties:
(Try)
type errOrObj = Error | $Shape<{||}>
const err: errOrObj = new Error("Blah")
const emptyObj: errOrObj = {}
const nonempty: errOrObj = {blah: 2} // Error
Try this:
const err: Error | {||} = Object.freeze({});
(Try)
See https://github.com/facebook/flow/issues/2977#issuecomment-390613203 and https://flow.org/en/docs/types/objects/#toc-unsealed-objects