-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Would it be good to use Babel for Transpiling ES.next features? #2254
Comments
I believe its unlikely given that ms is quite strong in the compiler field and they might not want to ie inherit/work-in another parser/compiler codebase. That said, i would very much appreciate that. This question for me boils down to the typescript/Angular announcement. I am unsure whether that was a good move (might be, just unsure for now). As i mentioned in #2261 typescript is not ES6 and is not clearly delineating which features are typescript specific and which are ES6 in their docs and specs since they just recently even started pushing for ES6 support. In general I believe the thinking in the team is typescript is Javascript with a whole lot of optional extra features you can use without being concerned too much with consensus towards ES6. Actually thats what held me back from looking into that to begin with. It looks like Javascript but its not really, you never actually know where specific non JS features where used, unless you looked at the entire codebase or compiled it all and diffed it. Generally though, provided Typescript is moving into a standards based direction with opt-in extra features i would very much appreciate the strength of the team behind typescript. Whether it makes sense to work with babel and opt-in extend for legacy typescript support or experimental would need discussion. |
If TypeScript sees itself as non-standard JS with type checking it would probably be more useful, if TypeScript wouldn't use Babel for standard JS transpiling (as it is non-standard), but modularize the type checking so it can be used with standard JS transpilers. (To say it differently: Instead of using Babel inside TypeScript as requested by me it would make more sense if I could use TypeScripts type checking outside of TypeScript like on top of Babel. That way TypeScript could keep its non-standard transpiling mechanisms.) |
I suggested pretty much the same in #1641 (at the time babel was still known as 6to5). The response from the TS team was clear: they are not going to use babel to transform ts/es6 code into es5. (The motivation for my suggestion was about speeding up the ES6 implementation process.) Of course, you are free to use TS with ES6 target and then pipe into Babel if you think Babel has better transforms.
I can't speak for the team but I'm curious where you got that impression. They have a clearly stated goal to align as much as possible with ES6/7 and several discussions on github suggestions/issues show that they are careful about adding "optional extra features". BTW I'm not even sure what are those "whole lot of optional extra features". Of course there's the typing, but that's the whole point of TS. Then what? Modules were added before standardization but they are now aligning on ES6 spec. public/private modifiers inside classes are an addition, although it's more at the typing level than anything else, as it doesn't translate |
As noted, the pros and cons here were pretty well covered in #1641. |
Sorry to re-open this here, but it seems like the best place. Considering Babel v6 came out, which uses a modular plugin approach - pretty much all the arguments that were previously used in the threads around this have fallen away and are no longer applicable. TypeScript's parsing and transpilation abilities would essentially just become babel plugins, with a typescript prefix. Flow Type went the babel route with its own babel plugins, allowing you to write ESNext code in Babel, then use babel to compile that source code to whatever target you want by just changing presets and/or plugins. Such adoption of Babel v6 would:
|
looks like there is some more interest in this approach: |
I'm interested in the approach... I think it's time to start bringing a bit of convergence into play in the greater JS ecosystem. |
Recently a lot of projects working on/with JavaScript language features unified or at least came together to create new standards. AtScript was "merged" into TypeScript, there is the https://github.com/estree/estree project from Babel, Acorn and Esprima folks... and so I wonder if it would be good - also in terms of separation of concerns -, if TypeScript would just use Babel internally for all transpiling tasks, so it essentially just puts all type-related logic on top of Babel. It seems there would be at least some interest from other devs in such task (https://twitter.com/wycats/status/573553751362928641).
TypeScript could be easily integrated on top of existing Babel projects and it would probably stabilize Babels and TypeScripts transpiling tasks (because of shared knowledge experience), which could result in getting new features faster.
The text was updated successfully, but these errors were encountered: