Hello, I was wondering if it would be possible to add strict type feature to the language.
strict type can be denoted as strict mode is by string literal
"strict type mode"
in this declare environment, the word "type", "strict", or better yet use constructor to denote the type, shall be treated as a keyword to denote a variable as strict, not changing type, if assign number, it can only be assigned number.
type num = 0;
strict num = 0;
if we use constructor to denote the type than the examples above shall be set to default false value of that type if no value is set at initialization for examples
Number num;// is the same as Number num = 0;
String str;// is the same as String str = "";
Object obj;// is the same as Object obj = null;
num = 1;//good
num = "a";//ERROR: variable cannot change type in strict type mode
This will make the language easy to compile to other languages and even to wasmjs possible.
coffescript and typescript are attempts to add this feature, and yes to a language like JavaScript, this is a feature as all the other features of this beautiful language made in chaos and rush.
I think this will do great for developers of dynamic and strict types of languages going into learning JavaScript.
I can imagine one of you coming up with this already, but it has been on my mind to at least attempt to get this feature requested, and so this is my attempt!
Keep up the good work, and thank you for advancing javascript / ecmascript!