2 ms·
Google's Closure JS Compiler has exactly what you are describing as an optional layer on top of Javascript inside jsdoc comments. In that, primitives are defaul
by esrauch 13y ago
Google's Closure JS Compiler has exactly what you are describing as an optional layer on top of Javascript inside jsdoc comments. In that, primitives are default non-nullable unless you include ? in the type (eg @type {number} is non-nullable, {?number} is nullable), whereas Objects are nullable by default unless you specify otherwise (eg @type {Object} is nullable, {!Object} is non-nullable).
It's a pretty good system that does what it can, but you can still pretty easily get code that violates your specified types at runtime if you go out of your way.