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;
}
export const enum Actions {
Hoge = 'containers/Hoge',
Fuga = 'containers/Fuga',
}
OUT:
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',
},
],
}