mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-09 11:40:07 +00:00
Add flux-standard-action
This commit is contained in:
26
flux-standard-action/flux-standard-action-tests.ts
Normal file
26
flux-standard-action/flux-standard-action-tests.ts
Normal 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);
|
||||
29
flux-standard-action/flux-standard-action.d.ts
vendored
Normal file
29
flux-standard-action/flux-standard-action.d.ts
vendored
Normal 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user