babel-plugin-s2s-action-creator-ts
v1.2.0
Published
generate action creator
Downloads
6
Readme
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',
},
],
}