-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
It has been known long ago that babel supports typescript via the babel-preset-typescript.
The work flow is something like
-
.tsfiles are converted to.jsfile with type annotation removed by babel. -
Concurrently, typescript type-checks the
.tsfiles viatsccommand.
How does typescript understands (parses) many custom syntax configured with babel? For example: @babel/plugin-proposal-optional-chaining
Is anyway to make babel just compile the code from Typescript into Typescript with custom syntax parsed. For example, I want babel to convert this code
const a: number = foo?.bar
into
const a: number = (_foo = foo) === undefined && _foo.bar
instead of
const a = (_foo = foo) === undefined && _foo.bar
If babel can do that, I can freely add any language features as I want without waiting for Typescript support.
Another way would be letting typescript ignore custom syntax configured with babel, and just do the type check.
However, IMO babel is too flexible for typescript to handle its supported syntax.
- Slack Community Chat: https://babeljs.slack.com (you can sign-up at https://slack.babeljs.io/ for an invite)
- StackOverflow: https://stackoverflow.com/questions/tagged/babeljs using the tag
babeljs - Twitter: If it's just a quick question you can ping our Twitter: https://twitter.com/babeljs
- Also have a look at the readme for more information on how to get support:
https://github.com/babel/babel/blob/master/README.md