Add flux-standard-action

This commit is contained in:
tkqubo
2015-09-28 00:44:02 +09:00
parent c560ba6f0f
commit 0932a926dc
2 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
/// <reference path="flux-standard-action.d.ts" />
//import action = require('flux-standard-action');
import { isError, isFSA, Action, ErrorAction } from 'flux-standard-action';
interface TextPayload {
text: string;
}
var sample1: Action<TextPayload> = {
type: 'ADD_TODO',
payload: {
text: 'Do something.'
}
};
var sample2: ErrorAction = {
type: 'ADD_TODO',
payload: new Error(),
error: true
};
var result1: boolean = isError(sample1);
var result2: boolean = isFSA(sample1);
var result3: boolean = isError(sample2);
var result4: boolean = isFSA(sample2);

View File

@@ -0,0 +1,29 @@
// Type definitions for flux-standard-action 0.5.0
// Project: https://github.com/acdlite/flux-standard-action
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "flux-standard-action" {
export interface ErrorAction extends Action<Error> {
error: boolean;
}
export interface Action<T> {
type: string;
payload?: T;
error?: boolean;
}
export interface AnyMeta {
meta: any
}
export interface TypedMeta<T> {
meta: T
}
export function isFSA(action: Action<any>): boolean;
export function isError(action: Action<any>): boolean;
}