0
我想设置的功能参数东西avaible值是这样的:是否可以预先定义函数参数的可用值?
let valueList = [
'val1',
'val2',
'val3',
];
let getSomething = (parameter: valueList) => {
// do something
}
而且我想在控制台上的错误,如果比什么都值列表变量等参数值。
而且这将是一件好事,如果IDE showup的可能值,当我调用该函数如下:
getSomething(| <- cursor) // when cursor here, the IDE show the possible values from valueList
所以你想要一个*枚举*? – Li357
可能的重复[如何在TypeScript中创建枚举类型?](https://stackoverflow.com/questions/12687793/how-to-create-enum-like-type-in-typescript) –
可能的重复[How使用有限的可能值在jsdoc中记录字符串类型](https://stackoverflow.com/questions/19093935/how-to-document-a-string-type-in-jsdoc-with-limited-possible-values) – skiilaa