Comment Comment by z3t4 Type systems do not thinking for you, you still have to make a type with a range check. So you could just as well write function foo(n) { if(n < 10 || n > 100) throw new Error("Expected n=" + n + " to be between 10 and 100"); return n*2; } And while you are at it you can write an unit test that is tested at compile time or in the editor/IDE. // assert(foo(10),20); parent z3t4 5 years ago