4 ms·
Google has enough resources for someone to write a transpiler that can take annotated JS and convert most of it to TypeScript. It's certainly much more pleasant
by TheAceOfHearts 8y ago
Google has enough resources for someone to write a transpiler that can take annotated JS and convert most of it to TypeScript. It's certainly much more pleasant than having to type random comments everywhere, which kinda makes syntax highlighting way less useful. Oh, and last I checked there were no editor plugins for linting Closure Compiler annotated code.
Another option would be to add TypeScript support to Closure Compiler, although it doesn't seem likely since there's no spec to guarantee compatibility.
I'd love to see Facebook, Google, and Microsoft team up in this space, instead of creating 3 separate but very highly similar tools.
Also, while we're talking about Closure, let's take a moment to appreciate its amazing UI toolkit [0]. I'd still consider many of their widgets to be the gold standard. It's written with desktop clients in mind and is incredibly feature-complete. I believe it also has pretty good accessibility, although I haven't personally tried that out. Oh, and don't forget the i18n as well! The closure library definitely has a lot of quirky aspects to it, but it's still quite amazing if you consider its age and how much stuff it supports. It's worth taking a few minutes to browse through their docs [1].
[0] https://google.github.io/closure-library/source/closure/goog/demos/index.html https://google.github.io/closure-library/source/closure/goog...
[1] https://google.github.io/closure-library/api/ https://google.github.io/closure-library/api/
- evmar 8y agoI couldn't tell from your wording if you knew this already, but we wrote a JS->TS converter too. I didn't call it out very clearly but it's the second to last link in the post. I am really sad that TypeScript gave up on their spec. It previously was one of the strengths of the language that I was happy to cite. I guess it's a common crutch for languages (Python and so on) to say "the implementation is the spec" but without a spec to guide you, you lose sight of which features are intentional or accidents or even what the distinction between the two are. The Closure library does has some great stuff in it. It's the accumulation of years of experience of working around lots of really subtle issues in lot of browsers. On the other side it also has a lot of code for issues that are obsolete, and it's hard to know which pieces are for what.
- bearforcenine 8y agoGoogle did a bit of work on converting Closure annotated JavaScript to TypeScript. It's called Gents and it's part of the Clutz project https://github.com/angular/clutz/tree/master/src/main/java/com/google/javascript/gents https://github.com/angular/clutz/tree/master/src/main/java/c... We used it at Lucid when we converted our codebase from Closure annotated JavaScript to TypeScript. https://www.lucidchart.com/techblog/2017/11/16/converting-600k-lines-to-typescript-in-72-hours/ https://www.lucidchart.com/techblog/2017/11/16/converting-60... Google has support for using TypeScript in Closure annotated JavaScript via Clutz: https://github.com/angular/tsickle https://github.com/angular/tsickle It also has support converting TypeScript to Closure annotated JavaScript via tsickle: https://github.com/angular/clutz https://github.com/angular/clutz Before we converted all of our codebase to TypeScript we used both Clutz and tsickle. It was complicated to setup, but it worked. Now we just use tsickle. It's great to get the optimization of the Closure Compiler while using TypeScript.
- int_19h 8y ago> I'd love to see Facebook, Google, and Microsoft team up in this space, instead of creating 3 separate but very highly similar tools. It'll probably happen anyway, but the current competition will determine which tool that will be. So far TS looks like it's winning it, but, clearly, not by a large enough margin that the industry coalesces around it - yet.
- k__ 8y agoTS included Flow features over the years (control flow based typing, strict null checks, etc.)
- bazza451 8y agohttp://www.syntaxsuccess.com/viewarticle/closure-compiler-vs-rollup-vs-webpack http://www.syntaxsuccess.com/viewarticle/closure-compiler-vs... - interesting article about how closure enables smaller bundle sizes. I agree, it would be cool for someone to do the same thing for Typescript, I seem to remember a repo a while back on Github that said someone was experimenting with it - cant for the life of me remember where though!
- bazza451 8y agodidn't read the other comment on this - https://github.com/angular/tsickle https://github.com/angular/tsickle was the repo