扫码关注官方订阅号
使用 flow 请问怎么让参数只能为可选值呢?
例如:
function test (x: number) { console.log(x); }
怎么让 x 期望是 数字 1 或者 2
走同样的路,发现不同的人生
enum XXOOType {XX = 1; OO = 2;};
function xxoo(type: XXOOType) {}
看了一下原来是flow,那就是这样
const xxoo_type = {XX: 1, OO: 2};
type XXOOType = $Values<typeof xxoo_type>;
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
enum XXOOType {XX = 1; OO = 2;};
function xxoo(type: XXOOType) {}
看了一下原来是flow,那就是这样
const xxoo_type = {XX: 1, OO: 2};
type XXOOType = $Values<typeof xxoo_type>;