Hacker News new | ask | show | jobs
by pkukkapalli 2201 days ago
I think there is a way to get all of the "good parts" of Typescript, mainly type checking, without introducing the bad, mainly transpiling. I recently started just running Typescript on Javascript files, where all of the types are specified via JSDocs. It was a refreshing experience, and I highly recommend. The Typescript website[1] has pretty good documentation for it.

[1]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported...

2 comments

Unfortunately their jsdoc stuff only exposes a subset of their typing capabilities, so you're leaving some advanced type goodies on the table.
They've been adding features on every release for at least a couple releases. Not sure when you last checked, but regardless, it's getting better.
Came here to upvote typescript with jsdocs too. We use it in our project and it’s been really helpful. No overhead and you get the nice dev experience of typed code. Been doing it for 2 years, have yet to encounter a situation that would be solved by using ts compilation.
I much prefer JS+JSDoc over Typescript when writing my own code. Typescript makes me feel overly constrained.

Also, I've been doing web dev for 25+ years now and I don't like the trend backward to waiting for code to "compile".

Although if you're going to have to compile, Svelte looks like a nice middle-ground.