Skip to content

Latest commit

 

History

History
75 lines (57 loc) · 1.4 KB

File metadata and controls

75 lines (57 loc) · 1.4 KB

babel-plugin-transform-ts-import

Build Status

TypeScript in JavaScript imports resolver.

Examples

// Before
import Hello from '.hello.ts';

// After
var _ref = function (exports) {
  Object.defineProperty(exports, \\"__esModule\\", {
    value: true
  });
  exports.default = void 0;

  var Hello = function Hello() {
    var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

    if (!props.name) {
      props.name = 'World';
    }

    return ''.concat('Hello, ').concat(props.name, '!');
  };

  var _default = Hello;
  exports.default = _default;
  return exports;
}({}),
    Hello = _ref.default;

Requirements

  • Babel 7+
  • TypeScript 2+

Installation

npm i -D babel-plugin-transform-ts-import

Usage

.babelrc

{
  "plugins": [
    ["transform-ts-import", {
        // .babelrc for inner ts transform. Default:
        "presets": [
            "@babel/preset-env",
            "@babel/preset-typescript"
        ],
        "generatorOpts": {
            "comments": false,
            "quotes": "single",
            "jsescOption": { "quotes": "single" }
        },
        "ast": true,
        "babelrc": false
    }]
  ]
}

Options

Look at https://babeljs.io/docs/en/options.