KonstantinSimeonov / tsx-control-statements

Control flow JSX/TSX elements that get compiled to plain old javascript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to use with @babel/preset-typescript

saeedShamloo opened this issue · comments

hello, I've checked your examples and you've used 'ts-loader' or 'awesome-typescript-loader'.
I will be grateful if you tell me how to use 'tsx-control-statements' with '@babel/preset-typescript'.

@saeedShamloo Short answer is that you can't make it work because of how @babel/preset-typescript works.

More detailed answer:
tsx-control-statements is kind of a compiler plugin for the typescript compiler, which means that tsx-control-statements can only transform code that is compiled with the typescript compiler. @babel/preset-typescript does not use the typescript compiler to output javascript - it basically just strips away the types and outputs the result, which hasn't undergone any transformations beyond that.