1.0.1 • Published 5 years ago

parcel-plugin-babel-typescript v1.0.1

Weekly downloads
170
License
MIT
Repository
github
Last release
5 years ago

Parcel plugin to use Babel instead of TSC

This plugin replace TSC by Babel allowing you to use any babel plugin magic inside .ts and .tsx files.

Example:

The proposal/plugin is going to be https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining

What it does is allow you to do undefined?.foo without it throwing an error.

You have to install my plugin and the babel plugins you want to use.

npm install parcel-plugin-babel-typescript @babel/plugin-proposal-optional-chaining

Then you need to add the babel configuration needed by my plugin, which is

.babelrc

{
  "presets": [
    "@babel/preset-typescript"
  ]
}

And the configuration needed by the babel plugin of your choice

.babelrc

{
  "presets": [
    "@babel/preset-typescript"
  ],
  "plugins": [
    "@babel/plugin-proposal-optional-chaining"
  ]
}

And voila, you can use TS/JSX features with Babel's magic at the same time !

const foo: number = 1
const bar = foo as unknown as string

const jsxStuff = <div></div>

const baz = undefined?.qux