3 ms·
TS type sludge is required to make the JS underneath workable. I'd welcome TS type system in Python, mypy and co. should steal it outright.
by baq 2y ago
TS type sludge is required to make the JS underneath workable.
I'd welcome TS type system in Python, mypy and co. should steal it outright.
- rednafi 2y agoI also work with Python, and I agree that TS has a better type system than Python. However, Python doesn’t require an additional compilation step, which is a win for it. That said, with tools like Bun, Deno, and Node now capable of running TS out of the box, that’s another win for TS.
- benrutter 2y agoI'm a Python developer, and use a bunch of types day-to-day, I haven't used TS aside from intermittent curiousity. Curious what aspects TS has that Python doesn't? (or that Python doesn't do as well)
- baq 2y agoI really like that TS makes it possible to work with raw objects (~dicts) without having to worry about keys existing or not existing, especially narrowing down via Pick<> and tricks related to impossible combinations via the never type are nice (e.g. if it has key 'a', it can't have key 'b' and vice versa). That said Python's typing doesn't sit still and I tuned out a couple of years ago, so all those things might be possible today via TypedDict, haven't checked).
- rednafi 2y agoSpot on. Record types and Pick/Omit in TS is something I miss in Python. It's still not there. TypedDict solves some of the issues but it's a lot more verbose than TS and isn't half as nice.
- rednafi 2y agoI work with both Python and TS. Python's type hints feel bolted onto the language, whereas TS feels more native. In Python, you have to import a whole bunch of stuff for typing, which adds runtime overhead. For example, typing a decorator means importing `ParamSpec`, `Callable`, and a bunch of other things. In TS, all of that is available in the global scope, so it’s way less cluttered. Plus, the type system in TS is a lot more powerful. Generic record types are way nicer in TS than in Python.