by jtchang · 3y ago · 0 comments
What does this mean? If you use typescript doesn't it prevent these types of bugs?
Imagine some pipe. You can put in some bytes and get some bytes out again. As far as you know, you have to put in 16 bit integers, and you get 16 bit integers out. You put that in your type system:
int16_t communicate(int16_t in);
Now what you don't know is that if you provide the remote system with the integer 0, it will send back a 0, followed by the string "hello world". Your type system can't catch that because you've never told it that it can happen. The axioms the static analysis was built on didn't match reality, and therefore the analysis itself isn't sound.Ideally you validate incoming data using jsonschema or whatnot.