Comment by js2

Comment by js2 9 days ago

1 reply

> It's not like python and typescript where you declare your input data to be one thing, and then receive something else

In Python that's likely to lead to a runtime TypeError, not so much in TS since at runtime it's JS and JS is weakly typed.

Besides, Python has Pydantic which everyone should really should be using. :-)

tgv 9 days ago

Only if you use a deserializer that's tied to your classes, and not put everything in a dict. And then only if the data encounters an operation that doesn't accept it. But many operations accept e.g. strings, arrays, ints and floats. Is there even an operation that throws a TypeError when using a float instead of int?

Pydantic only helps (AFAIK) when you're letting it help, and you actually use the correct type information. It's not difficult to use, but it's optional, and can be faulty.