TypeScript can use JSdoc annotations: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-i...
Thanks, but from a bit of research it's not clear to me: does this mean that it's possible to use TypeScript to type-check javascript files which include these annotations, without using .ts at all?
Yes, by using --allowJS and --checkJS switches (can also be set in tsconfig.json).
Thanks a lot - will try this!
I would love to have type checking, but I'm weary of solutions that aren't really JS, and could fall out of favor or lack good support in the future. I'm pretty sure I'm not the only one.
But Flow type annotations don't really need an incompatible syntax AFAIK; they could just use comments. This way, we wouldn't need to worry about the future of Flow. If the projects dies off or becomes redundant, we're just left with some useful comments - no need to rewrite or transpile our code to native JS.
PS I found an existing project which does this [1], but it requires an additional step and it isn't officially supported. It looks incredibly easy to make Flow work directly with pure JS with comments...
[1] https://github.com/Kegsay/flow-jsdoc