|
|
|
|
|
by hkolek
5187 days ago
|
|
The google closure compiler does this. You can optionally annotate your javascript functions with type information (JavaDoc style) and the compiler will enforce it. For example: /**
* @param {Function} fn
* @param {string|null|undefined} str
*/
foo.bar = function(fn, str) {
// do something
}
It is pretty powerful, you can also do some generics-like stuff like "@param {Array.<string>}" to enforce an array with only strings as elements. |
|