3 ms·
I'm asking this from a position of massive ignorance (I'm mostly a backend dev who does the occasional website), but is there any type hinting tooling in the Ja
by Karunamon 9y ago
I'm asking this from a position of massive ignorance (I'm mostly a backend dev who does the occasional website), but is there any type hinting tooling in the Javascript ecosystem? Python has PEP484 where you annotate types in either comments or docstrings, Ruby has YARD tags used similarly, and smart IDEs can pick up on these and offer decent refactoring tools.
But does anything similar exist in JS land?
- dgreensp 9y agoTypeScript is fast becoming the go-to language for JavaScript with types.
- jmsaucier 9y agoI will second this. I've seen some people choose FB's Flow as their type checker, but for me, I'm loving Typescript. It has minor problems when it has to use DefinitelyTyped and integrate with other frameworks, but those are minor in comparison to not having it.
- edem 9y agoThey still didn't manage to put together a usable language. Just try to import your `Foo` class into `Bar` and your `Bar` class into `Foo`. BOOM! It will explode into your face. And this is just a basic thing which should work in a real language.
- avarun 9y agoFlow does this very well. https://flow.org/ https://flow.org/
- SlySherZ 9y agoYes, there is JSDoc[1] which allows you to add type annotations in comments, that can then be used by some tool. The VSCode editor is able to leverage the TypeScript engine even with vanilla JS to automatically infer types and also supports JSDoc. Basically you write vanilla JS, add JSDoc comments here and there when the inference doesn't work as you want and it gives you most benefits of a typed language, without tying yourself to a specific ecosystem (your teammates could be using something else entirely). It works pretty well. [1] http://usejsdoc.org/ http://usejsdoc.org/
- Karunamon 9y agoThis is more what I was looking for; the others appear to be supersets of JS.