|
|
|
|
|
by cryptica
2559 days ago
|
|
This is incorrect, merely declaring a type for all your API inputs does not prevent clients (especially a bad actor) from actually sending objects of different types at runtime;
and when they do, your code will crash catastrophically. Try it. You need to do manual schema validation, just like you did with JavaScript. TypeScript adds 0 value. The type only gives you an illusion of safety, which is worse than no safety at all. |
|
Typescript makes sure that all your code agrees with the protocol definition you have chosen. That alone is immensely valuable.