@yuyi919/ts-transformer-awesome
TypeScript icon, indicating that this package has built-in type declarations

0.1.31 • Public • Published

@yuyi919/ts-transformer-awesome

npm npm

What is CustomTransformer ?

interface CustomTransformers {
  /** Custom transformers to evaluate before built-in .js transformations. */
  before?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[];
  /** Custom transformers to evaluate after built-in .js transformations. */
  after?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[];
  /** Custom transformers to evaluate after built-in .d.ts transformations. */
  afterDeclarations?: (TransformerFactory<Bundle | SourceFile> | CustomTransformerFactory)[];
}

Api

const { getCustomTransformers } = require('@yuyi919/ts-transformer-awesome')

// ts.createProgram(...)
getCustomTransformers({
  program, // ts.Program
  importLibs: [
    'lodash',
    ['@material-ui/core', {
      libraryDirectory: '',
      camel2DashComponentName: false
    }]
  ] // use ts-import-plugin
  // ...
}) // { before: [...], after: [...] }

global env

import '@yuyi919/ts-transformer-awesome/env'

Basic

ts-nameof

点击此处查看更多

ts-transformer-keys

就像使用ts-transformer-keys一样

interface A {
  a: number;
  b: number;
}
tsKeys<A>() // => ["a", "b"]

点击此处查看更多

tsx-control-statements

就像使用tsx-control-statements一样

// 转换前
const TsxControlStatments = () => {
  return (
    <For of={[1, 2, 3]} each="item" index="itemIndex">
      <a style={{ background: 'red' }}>{itemIndex}{item}</a>
    </For>
  );
}

// 转换后
var TsxControlStatments = () => {
  return Array.from([1, 2, 3], function (item, itemIndex) {
    return React.createElement("a", {
      style: __$hoisted_o0
      /**
       * 此处是`@avensia-oss/ts-transform-hoist-objects-in-props`在发挥作用 
       */
    }, itemIndex);
  });
}
// 自动静态化转译
var __$hoisted_o0 = {
  background: 'red'
};

点击此处查看更多

Readme

Keywords

none

Package Sidebar

Install

npm i @yuyi919/ts-transformer-awesome

Weekly Downloads

9

Version

0.1.31

License

MIT

Unpacked Size

213 kB

Total Files

83

Last publish

Collaborators

  • yuyi919606952