3 ms·
Or maybe just use jsdoc at this point and skip the compile step completely. Though i admit it is not as pretty to read but you can get used to it. Still a nift
by cardanome 2y ago
Or maybe just use jsdoc at this point and skip the compile step completely. Though i admit it is not as pretty to read but you can get used to it.
Still a nifty new tool though. I wish JS would just allow type declarations at this point. It doesn't need to enforce them, just allow them like Python does. That would be amazing.
- Fannon 2y agoAt least Node.js has added experimental support that seems to do that: https://github.com/nodejs/node/pull/53725 https://github.com/nodejs/node/pull/53725 But this is just an on-the-fly transpile(natively supported). It would be much better if JavaScript would go the Python route. For that they would have to extend the EcmaScript spec (to be safe) I guess. Just using JSDoc is imho not a good alternative. The big benefit of TypeScript is that your compiler checks this all for you. I've seen to much incomplete or wrong JSDoc in my life.. also a nightmare to maintain.
- CraigJPerry 2y agohttps://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html https://www.typescriptlang.org/docs/handbook/jsdoc-supported...
- com2kid 2y agoYou can shove @ts-check on the top of js files and get some decent checks going on. It isn't 100% but it'll be pretty darn good.
- jauntywundrkind 2y agoThis feels like the sort of thing that would be nice to have ide support for. Open a js file with ts comments, and it silently converts to ts editing. Save the file and it converts ts back to js with comments before actually writing.
- matharmin 2y agoThere is a proposal for that: https://github.com/tc39/proposal-type-annotations https://github.com/tc39/proposal-type-annotations