top | item 40920323

(no title)

novagameco | 1 year ago

Well python allows for type annotations as part of the language; javascript does not, so the compilation stage in typescript is just about erasing types for the most part (typescript tries to have minimal impact on the runtime). It just seems like a worse option than typescript's syntax. Bun runs typescript natively without doing any of the type checking

discuss

order

wilsonnb3|1 year ago

Even though type annotations are part of the language now in Python, they aren’t used by the runtime so it is still essentially the same as jsdoc or sorbet style type checking. More like a really powerful linter than a transpiler like typescript.

Before type annotations were officially added in python 3.5, you could still use mypy for type checking. The only difference being that the type hint format wasn’t standardized across tools.

satvikpendem|1 year ago

But...TypeScript is the same, types are not used by the runtime.

botten|1 year ago

With types as jsdoc annotations there is no compilation step at all, no matter where the script runs. Have your cake and eat it.

satvikpendem|1 year ago

JSDoc is strictly less powerful than TypeScript though. For example, more complex types as well as template literal types are impossible to have in JSDoc. It is simply more ergonomic to use TypeScript instead of JSDoc.

novagameco|1 year ago

Are you saying there isn't any tool which checks whether you're using your types correctly? If not, then the two aren't comparable at all