mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-22 20:37:58 +08:00
Merge pull request #17485 from Kovensky/patch-5
flux-standard-action: fix typos, declare assertions
This commit is contained in:
@@ -23,3 +23,17 @@ var result1: boolean = isError(sample1);
|
||||
var result2: boolean = isFSA(sample1);
|
||||
var result3: boolean = isError(sample2);
|
||||
var result4: boolean = isFSA(sample2);
|
||||
|
||||
declare function alert (message: string): void
|
||||
|
||||
function unwrapAction(action: { type: string }) {
|
||||
if (isFSA(action)) {
|
||||
if (isError(action)) {
|
||||
alert(action.payload!.message)
|
||||
}
|
||||
return action.payload
|
||||
}
|
||||
}
|
||||
|
||||
var result5: TextPayload = unwrapAction(sample1)
|
||||
var result6: Error = unwrapAction(sample2)
|
||||
|
||||
10
types/flux-standard-action/index.d.ts
vendored
10
types/flux-standard-action/index.d.ts
vendored
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
export interface ErrorAction extends Action<Error> {
|
||||
error: boolean;
|
||||
error: true;
|
||||
}
|
||||
|
||||
export interface Action<T> {
|
||||
@@ -14,16 +14,16 @@ export interface Action<T> {
|
||||
error?: boolean;
|
||||
}
|
||||
|
||||
// Usage: var action: Action<sring> & AnyMeta;
|
||||
/** Usage: `var action: Action<string> & AnyMeta;` */
|
||||
export interface AnyMeta {
|
||||
meta: any
|
||||
}
|
||||
|
||||
// Usage: var action: Action<sring> & TypedMeta<string>;
|
||||
/** Usage: `var action: Action<string> & TypedMeta<string>;` */
|
||||
export interface TypedMeta<T> {
|
||||
meta: T
|
||||
}
|
||||
|
||||
export declare function isFSA(action: any): boolean;
|
||||
export declare function isFSA(action: any): action is Action<any>;
|
||||
|
||||
export declare function isError(action: any): boolean;
|
||||
export declare function isError(action: any): action is ErrorAction;
|
||||
|
||||
Reference in New Issue
Block a user