const values_array = [
1,
2,
3,
4
] as const;
type VALUE_TYPE = typeof values_array[number];
function dosomething(value:VALUE_TYPE){
// ...dosomething
}
这样在调用时就有友好的代码提示了。
const values_array = [
1,
2,
3,
4
] as const;
type VALUE_TYPE = typeof values_array[number];
function dosomething(value:VALUE_TYPE){
// ...dosomething
}
这样在调用时就有友好的代码提示了。