Roman Pokrovskij
Roman Pokrovskij

Reputation: 9776

How to compile typescript with babel 7 cli?

This:

babel ./src/MyTypescript.ts  --out-dir ./wwwroot/js/

doesn't work (no error, just '0 compiled').

.babelrc contains everything that Babel 7 need to compile typescript with webpack babel loader: preset "@babel/typescript" and plugin "babel-plugin-transform-class-properties" (pair which works for me with current babel 7 rc01).

Upvotes: 1

Views: 3183

Answers (2)

cbdeveloper
cbdeveloper

Reputation: 31365

The selected answer did not work for me.

I've solved with the help of the following link:

https://github.com/microsoft/TypeScript-Babel-Starter/blob/master/package.json

"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline"

To add the TS extensions:

--extensions \".ts,.tsx\"

Upvotes: 3

Roman Pokrovskij
Roman Pokrovskij

Reputation: 9776

Here is an answer:

 babel ./src/MyTypescript.ts  --out-dir ./wwwroot/js/ --extensions '.ts,.js'

Upvotes: 6

Related Questions