|
|
|
|
|
by rewma
1716 days ago
|
|
> This is true for values defined in code, but TypeScript cannot directly see data that comes in from eg. an API, and so can't infer types from it. No, that's not right at all. TypeScript allows you to determine the exact type of an object in any code path through type assertions and type guards. With TypeScript you can get an any instance from wherever, apply your checks, and from thereon either throw an error or narrow your any object into whatever type you're interested in. I really do not know what leads you to believe that TypeScrip cannot handle static typing or input validation. |
|