3 ms·
Does BuckleScript do any runtime type checking? If not, you have the same problem the moment you call out into any pure JS library - your type annotations say w
by int_19h 8y ago
Does BuckleScript do any runtime type checking? If not, you have the same problem the moment you call out into any pure JS library - your type annotations say what you expect, but JS code can merrily give you something else.
- baddox 8y agoThat just means the type annotations are incorrect, and how would runtime type checking solve that?
- int_19h 8y agoIt wouldn't solve that, but it would prevent the code from running with data that is incorrect according to type annotations. Think of it as a runtime assert that is automatically generated from the compile-time type annotation. (Unfortunately, the JS runtime object model does not allow for such runtime type checks to be performed with reasonable performance.)
- 52-6F-62 8y agoI have to admit, as much as I enjoy working with TypeScript— this same problem is always on my mind. I find myself continually writing the same tests for type safety that I would in JS. I have to remind myself that, yes the types are safe while writing, but still not quite at runtime. It can lead to pretty fundamental flaws if you’re not careful.