Skip to content

Commit

Permalink
Add semi-colon, move tsc to posttest
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Nov 19, 2016
1 parent f542e79 commit 31f0e76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"lint": "eslint src/ test/",
"prepublish": "npm test && npm run build",
"pretest": "npm run lint",
"test": "cross-env NODE_ENV=test nyc mocha && tsc"
"test": "cross-env NODE_ENV=test nyc mocha",
"posttest": "tsc"
},
"repository": {
"type": "git",
Expand Down
36 changes: 18 additions & 18 deletions test/typings-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FluxStandardAction, isError, isFSA } from '../src'
import { FluxStandardAction, isError, isFSA } from '../src';

interface CustomPayload {
a: number
Expand All @@ -16,53 +16,53 @@ function createCustomAction(payload: CustomPayload): FluxStandardAction<CustomPa
return {
type: 'custom',
payload
}
};
}

function isCustomAction(action: FluxStandardAction<any, any>): action is FluxStandardAction<CustomPayload, any> {
return isFSA(action) && action.type === 'custom'
return isFSA(action) && action.type === 'custom';
}

function isCustomAction2(action: FluxStandardAction<any, any>): action is FluxStandardAction<CustomPayload, CustomMetadata> {
return isFSA(action) && action.type === 'custom2'
return isFSA(action) && action.type === 'custom2';
}

function isCustomAction3(action: any): action is FluxStandardAction<void, string> {
return isFSA(action) && action.type === 'custom3'
return isFSA(action) && action.type === 'custom3';
}

function reducer(state, action) {
if (isFSA<CustomPayload, void>(action)) {
let a: number = action.payload.a
let a: number = action.payload.a;
}
else if (isFSA<CustomPayload, CustomMetadata>(action)) {
let a: number = action.payload.a
let b: string = action.meta.b
let a: number = action.payload.a;
let b: string = action.meta.b;
}
else if (isFSA<void, string>(action)) {
let meta: string = action.meta
let meta: string = action.meta;
}
else if (isError(action)) {
let iserr: true = action.error // iserr === true
let err: Error = action.payload
let iserr: true = action.error; // iserr === true
let err: Error = action.payload;
}
else if (isError<MyError, void>(action)) {
let err: MyError = action.payload
let someFieldValue: string = err.someField
let err: MyError = action.payload;
let someFieldValue: string = err.someField;
}
}

function reducer2(state, action) {
if (isCustomAction(action)) {
let a: number = action.payload.a
let a: number = action.payload.a;
}
else if (isCustomAction2(action)) {
let a: number = action.payload.a
let b: string = action.meta.b
let a: number = action.payload.a;
let b: string = action.meta.b;
}
else if (isCustomAction3(action)) {
let meta: string = action.meta
let meta: string = action.meta;
}
}

let action = createCustomAction({ a: 123 })
let action = createCustomAction({ a: 123 });

0 comments on commit 31f0e76

Please sign in to comment.