为 ES2016 提出的类型化对象可以用于约束参数的 API 吗?
例如:
function foo(options){
// I want to guarantee that `options` has a single string property `bar`.
// Can typed objects help me with this?
}
ECMA 文档:
- http://wiki.ecmascript.org/doku.php?id=harmony:typed_objects
- https://github.com/dslomov/typed-objects-es7
这是对较早问题的编辑。