Skip to content

Commit 6919306

Browse files
unionalJaKXz
authored andcommitted
feat(action.type): remove Symbol from allowed types (#86)
BREAKING: `type` now *must* be a string constant. Resolves #39. Resolves #9.
1 parent cc178cf commit 6919306

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ An action MUST NOT include properties other than `type`, `payload`, `error`, and
6262

6363
### `type`
6464

65-
The `type` of an action identifies to the consumer the nature of the action that has occurred. By convention, `type` is usually a string constant or a Symbol. If two types are the same, they MUST be strictly equivalent (using `===`).
65+
The `type` of an action identifies to the consumer the nature of the action that has occurred. `type` is a string constant. If two types are the same, they MUST be strictly equivalent (using `===`).
6666

6767
### `payload`
6868

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface FluxStandardAction<Payload, Meta> {
33
* The `type` of an action identifies to the consumer the nature of the action that has occurred.
44
* Two actions with the same `type` MUST be strictly equivalent (using `===`)
55
*/
6-
type: string | symbol;
6+
type: string;
77
/**
88
* The optional `payload` property MAY be any type of value.
99
* It represents the payload of the action.

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import {
22
isPlainObject,
33
isString,
4-
isSymbol,
54
} from 'lodash';
65

76
export function isFSA(action) {
87
return (
98
isPlainObject(action) &&
10-
(isString(action.type) || isSymbol(action.type)) &&
9+
isString(action.type) &&
1110
Object.keys(action).every(isValidKey)
1211
);
1312
}

test/isFSA.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { isFSA } from '../src/';
22

33
const type = 'ACTION_TYPE';
4-
const symbolType = Symbol.for(type);
54

65
describe('isFSA()', () => {
76
it('requires a type', () => {
@@ -17,9 +16,7 @@ describe('isFSA()', () => {
1716
expect(isFSA(action)).toBe(false);
1817
});
1918

20-
it('only returns true if type is a string or symbol', () => {
21-
// remove this assertion if/when symbol support is dropped
22-
expect(isFSA({ type: symbolType })).toBe(true);
19+
it('only returns true if type is a string', () => {
2320
expect(isFSA({ type: true })).toBe(false);
2421
expect(isFSA({ type: 123 })).toBe(false);
2522
});

0 commit comments

Comments
 (0)