3 ms·
Same here. I still do not get it. I see the benefits of typed languages for use cases controlling binary data, like hardware controlling, drivers or binary file
by Aldipower 6y ago
Same here. I still do not get it. I see the benefits of typed languages for use cases controlling binary data, like hardware controlling, drivers or binary file formats.
And actually you can write very type safe code in pure JavaScript.
1.
(arg) => if (typeof arg !== "string) throw new Error()
Of course, this is executed during runtime (which could have benefits too sometimes) and not at transpile time.
Yes, you can laugh at me. But.. You should be always aware of the types you are using, which data is coming in and if the function is type critical, which is only the case for some functions, it is even more fault safe doing it this way, because your app is spitting an error during runtime, which will definitely be fixed very quickly. :)
To validate data, use typed structs.
2.
You need to write good tests anyway.
Tests should test with malformed and faulty data always.
I and the teams I had, maintained and coded big JS applications. I can remember only one case, where TypeScript could have been helped with typing. But also, we had no test written for it, so..