if I create this Flow type:
export type List = [
'some' |
'strings' |
'allowed' |
'to' |
'use'
];
I am not allowed to:
const myList: List = [];
this is the error:
empty array literal:
This type is incompatible with a tuple type that expects a 1st element of non-optional type string enum
The only thing I can come up with is adding typeof undefined
to the possible values list. But there must be a simpeler way to allow it to be empty?
You defined a tuple of one element, you may want
type Element =
'some' |
'strings' |
'allowed' |
'to' |
'use';
export type List = Element[];
// or export type List = Array<Element>;
const myList: List = []
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