is it possible to use TypeScript and Babel together

7.9k views Asked by At

I am new to both TypeScript and Babel. I have researched both and found they have features the other does not have. I'd like get the best of both world by using TypeScript to organize my code then use babels ES6 features like asyc/await and others. Is this possible.

1

There are 1 answers

3
basarat On BEST ANSWER

I'd like get the best of both world by using TypeScript to organize my code then use babels ES6 features like asyc/await and others. Is this possible.

Not out of the box. I would recommend against it unless you are willing to start compiler hacking yourself. Reason is that since TypeScript doesn't understand async await yet you need to put babel before TypeScript and then the output generated by Babel will not be ideal TypeScript compilation target.

That said TypeScript should get async/await soon (3 / 4 months)

Update

You can now use TypeScript async/await with --target es6 and then use babel as a secondary transpiler.

In fact atom-typescript supports typescript -> babel -> js out of the box : https://github.com/TypeStrong/atom-typescript/blob/master/docs/faq.md#can-i-use-an-alternate-transpiler