Skip to content

Commit 58840bc

Browse files
authored
Update typings-test.ts
1 parent fb671f5 commit 58840bc

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/typings-test.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface CustomPayload {
55
}
66

77
interface CustomMetadata {
8-
b: string;
8+
b?: string;
99
}
1010

1111
interface MyError extends Error {
@@ -47,10 +47,14 @@ function reducer(state, action) {
4747
}
4848
else if (isFSA<CustomPayload, CustomMetadata>(action)) {
4949
let a: number = action.payload.a;
50-
let b: string = action.meta.b;
50+
let b: string | undefined;
51+
52+
if (typeof action.meta !== "undefined") {
53+
b = action.meta.b;
54+
}
5155
}
5256
else if (isFSA<void, string>(action)) {
53-
let meta: string = action.meta;
57+
let meta: string | undefined = action.meta;
5458
}
5559
else if (isError(action)) {
5660
let iserr: true = action.error; // iserr === true
@@ -68,10 +72,14 @@ function reducer2(state, action) {
6872
}
6973
else if (isCustomAction2(action)) {
7074
let a: number = action.payload.a;
71-
let b: string = action.meta.b;
75+
let b: string | undefined;
76+
77+
if (typeof action.meta !== "undefined") {
78+
b = action.meta.b;
79+
}
7280
}
7381
else if (isCustomAction3(action)) {
74-
let meta: string = action.meta;
82+
let meta: string | undefined = action.meta;
7583
}
7684
}
7785

0 commit comments

Comments
 (0)