在打字稿中对数组进行详尽的类型检查

问题描述

我正在尝试从类型别名为数组创建详尽的类型检查。

type Elevation = '1' | '2' | '3';

type SomeExhaustiveType = ???

const elevationArray: SomeExhaustiveType<Elevation>[] = ['1','2']; // <-- show error here because 3 is not in the array

是否可以检查type Elevation的所有成员是否都在elevationArray中?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)