logoalt Hacker News

mplanchard04/01/20253 repliesview on HN

Sure, you're technically correct. But TS is compiled in to JS, which is dynamically typed at runtime. You're still ultimately in a dynamically typed language.

In addition, in a typical statically typed, compiled language, your only place where you interact with data that isn't guaranteed to be type-conformant is at a foreign function interface, whereas in Typescript all your interaction with third-party libraries is via regular JS and may or may not be type conformant.


Replies

throwaway89434504/01/2025

Rust compiles into WASM, x86, etc, which are dynamically typed for all intents and purposes. They certainly don't understand or enforce Rust's type system invariants any more than JavaScript enforces TypeScript invariants. If you call a Rust function from WASM and pass it malformed data, the WASM runtime will happily execute it.

(pretty sure WASM actually has some integer types, so I guess maybe it is technically "statically typed" but not in any interesting sense--we could similarly say that JavaScript is "statically typed" because every variable has a static "any" type).

recursive04/01/2025

Is there such a thing as a statically typed language? CPU opcodes don't type-check their parameters.

johnfn04/02/2025

And Go/C/Rust compiles to ASM, a dynamically typed language at runtime.