使用 flow 请问怎么让参数只能为可选值呢?
例如:
function test (x: number) {
console.log(x);
}
怎么让 x 期望是 数字 1 或者 2
使用 flow 请问怎么让参数只能为可选值呢?
例如:
function test (x: number) {
console.log(x);
}
怎么让 x 期望是 数字 1 或者 2
13 回答13k 阅读
7 回答2.1k 阅读
3 回答1.3k 阅读✓ 已解决
6 回答1.2k 阅读✓ 已解决
2 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
6 回答1.1k 阅读
enum XXOOType {XX = 1; OO = 2;};
function xxoo(type: XXOOType) {}
看了一下原来是flow,那就是这样
const xxoo_type = {XX: 1, OO: 2};
type XXOOType = $Values<typeof xxoo_type>;