bring strict type into javascript / ecmascript

There's been a handful of different discussions around this idea on this form, so if you want to read up a bit on prior discussion, you can do a quick search for "type" and click on anything that sounds interesting. In particular, this thread proposes a somewhat similar idea, about adding support to set variables to specific types.

I would like to ask for a bit of clarification on your idea. If I write this code:

function doThing(String myStr) { ... }
doThing(2)

Is this a runtime error? Or a loadtime error? Or both (it checks for type errors at loadtime, and at runtime, in case it missed anything)?

Also, sorry, I have to nitpick a bit - CoffeeScript didn't actually provide any type-related features, it was merely an alternative syntax for JavaScript (it provided things like class syntax and optional chaining long before JavaScript had them)

1 Like