Proposal static type constraints features
喻恒春
achun.shx at qq.com
Sun Jun 3 07:53:34 UTC 2018
Hello all,
Sorry, I submitted a issue on the tc39/proposals/issues/146. It seems to be a mistake.
This proposal adds static type constraints features to ECMAScript, based on the existing syntax, just use the features of void.
It is located in the variable initial value or declares the parameter default value or the first statement of the body of the function.
Example: not all
```js
function CustomName(x = void ['', Number, mod.BigNumber]) {
// Declarative results type, and the default value is not available
void String;
// same as void [String]
// This function must eventually return a string
// ...
}
class CustomClass {
// ...
}
class PureStructure {
constructor() {
void {
name: void [!'',String], // must be a name
age: void [!0, Number], // must be age
email: void String
};
}
}
class ClassPrototype {
constructor() {
void {
name: String,
age: Number,
email: String
};
}
}
class FunctionPrototype {
constructor() {
void [[
String,
Number,
String
]];
}
}
```
Very embarrassing, my English is not awesome, so.........
See https://github.com/achun/proposal-static-type-constraints-features
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180603/4cc3caa6/attachment.html>
More information about the es-discuss
mailing list