Skip to content

Commit 1d7cb4b

Browse files
committed
Merge branch 'prevent-stringified-undefined' of https://github.com/matthamil/redux-logic into matthamil-prevent-stringified-undefined
2 parents 49cfab7 + 6ceefdd commit 1d7cb4b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/createLogic.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ export default function createLogic(logicOptions = {}) {
168168
throw new Error('type is required, use \'*\' to match all actions');
169169
}
170170

171+
if (type === 'undefined') {
172+
throw new Error('type is a string "undefined", check the logicOptions type field for a stringified undefined value');
173+
}
174+
171175
if (validate && transform) {
172176
throw new Error('logic cannot define both the validate and transform hooks they are aliases');
173177
}

test/createLogic.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ describe('createLogic', () => {
1919
createLogic({});
2020
}).toThrow(/type.*required/);
2121
});
22+
23+
it('throws type cannot be "undefined" error', () => {
24+
expect(() => {
25+
createLogic({
26+
type: `${undefined}`
27+
});
28+
}).toThrow(/type.*undefined/);
29+
});
2230
});
2331

2432
describe('warnTimeout', () => {

0 commit comments

Comments
 (0)