2 ms·
>risk runtime type errors. This is the part that's missing. Or more completely there's no runtime types at all. So you can't do stuff like: result = fet
by treis 3y ago
>risk runtime type errors.
This is the part that's missing. Or more completely there's no runtime types at all. So you can't do stuff like:
result = fetch....
if(result is User){
return result
}else{
Throw error
}
The mechanism TS gives you to do that is essentially recreating all your type rules in a validation. Which is keeping the same information in two places and risks them getting out of sync.
Most people pick up a library that generates the types and validations for you to solve this. Which works but it's kind of weird that you have to.
- epolanski 3y ago> Most people pick up a library that generates the types and validations for you to solve this. Which works but it's kind of weird that you have to. Why would it? Which static languages include automatic parsing at boundaries? Elm sort of does on ports, but that's like the only example I can think of, I'm perfectly sure that I may not know enough about it.