Flowtype:可能的字符串数组不能为空?

Flowtype: array of possible strings cannot be empty?

如果我创建此流程类型:

export type List = [
    'some' |
    'strings' |
    'allowed' |
    'to' |
    'use'
];

我不允许: const myList: List = [];

这是错误: empty array literal: This type is incompatible with a tuple type that expects a 1st element of non-optional type string enum

我唯一能想到的就是将 typeof undefined 添加到可能的值列表中。但是必须有更简单的方法让它为空吗?

您定义了一个元素的元组,您可能需要

type Element = 
  'some' |
  'strings' |
  'allowed' |
  'to' |
  'use';

export type List = Element[];
// or export type List = Array<Element>;

const myList: List = []