babel-plugin-s2s-action-creator-ts

1.2.0 • Public • Published

babel-plugin-s2s-action-creator-ts

plugin for https://github.com/akameco/s2s

Install

$ npm install --save-dev babel-plugin-s2s-action-creator-ts

Example

Basic

IN:

import External from 'external';
export type Action = Hoge | Fuga;
 
export interface Hoge {
  type: Actions.Hoge;
  key: number;
  data: External;
}
export interface Fuga {
  type: Actions.Fuga;
}
 
/***** Do not edit below this line *****/
export const enum Actions {
  Hoge = 'containers/Hoge',
  Fuga = 'containers/Fuga',
}

OUT:

/***** Do not edit this file *****/
import External from 'external';
import { Actions, Hoge, Fuga } from "./actionTypes";
export function hoge(key: number, data: External): Hoge {
  return {
    type: Actions.Hoge,
    key,
    data 
  };
}
export function fuga(): Fuga {
  return {
    type: Actions.Fuga
  };
}

Usage

module.exports = {
  watch: './**/*.ts',
  plugins: [
    {
      test: /actionTypes.ts$/,
      output: 'actions.ts',
      plugin: 's2s-action-creator-ts',
    },
  ],
}

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-s2s-action-creator-ts

Weekly Downloads

3

Version

1.2.0

License

MIT

Last publish

Collaborators

  • kamijin_fanta