Skip to content

Commit 5ceaa51

Browse files
author
keenondrums
committed
Minor code cleanup
1 parent 95d1bf0 commit 5ceaa51

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reducer-class",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Boilerplate free class-based reducer creator. Built with TypeScript. Works with Redux and NGRX. Has integration with immer.",
55
"main": "dist/index.js",
66
"scripts": {

src/decorator-action.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export interface IAction {
77
export type IActionCreator = (...args: any[]) => IAction
88
export type IActionConstructor = new (...args: any[]) => IAction
99
const isArrowFunction = (action: IActionConstructor | IActionCreator): action is IActionCreator => !action.prototype
10-
const isES6Class = (action: IActionConstructor | IActionCreator): boolean => action.toString().indexOf('class') === 0
1110
const typeGuardActionHasOwnType = (action: IAction | IActionConstructor | IActionCreator): action is IAction =>
1211
typeof (action as IAction).type === 'string' // tslint:disable-line strict-type-predicates
1312
const typeGuardActionIsString = (action: IAction | IActionConstructor | IActionCreator | string): action is string =>
@@ -20,11 +19,6 @@ const getActionType = (action: IAction | IActionConstructor | IActionCreator | s
2019
if (typeGuardActionHasOwnType(action)) {
2120
return action.type
2221
}
23-
// ES6 classes can not be invoked without `new` so we handle them separately
24-
if (isES6Class(action)) {
25-
const classInstance = new (action as IActionConstructor)()
26-
return classInstance.type
27-
}
2822
try {
2923
if (isArrowFunction(action)) {
3024
const actionCreatorArrowFnRes = action()

0 commit comments

Comments
 (0)