Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit d4d973d

Browse files
committed
feat: Update the way the types work
1 parent 0b9574a commit d4d973d

11 files changed

+63
-82
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"semantic-release": "semantic-release"
3434
},
3535
"peerDependencies": {
36-
"reactotron-core-client": "^2.2.1",
36+
"reactotron-core-client": "^2.5.0-beta.1",
3737
"redux": "^4.0.1"
3838
},
3939
"devDependencies": {
@@ -56,7 +56,7 @@
5656
"jest": "^24.1.0",
5757
"npm-run-all": "^4.1.5",
5858
"prettier": "^1.16.4",
59-
"reactotron-core-client": "^2.2.1",
59+
"reactotron-core-client": "^2.5.0-beta.1",
6060
"redux": "^4.0.1",
6161
"rollup": "^1.1.2",
6262
"rollup-plugin-babel": "^4.3.2",

reactotron-redux.d.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/commandHandler.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import createCommandHandler from "./commandHandler"
22
import { DEFAULT_REPLACER_TYPE } from "./reducer"
3+
import { PluginConfig } from "./pluginConfig"
34

45
// TODO: Write more tests around onBackup and onRestore.
56

src/commandHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import stateCleaner from "./helpers/stateCleaner"
22
import pathObject from "./helpers/pathObject"
33
import createSubscriptionsHandler from "./subscriptionsHandler"
4+
import { PluginConfig } from "./pluginConfig"
45

56
export default function createCommandHandler(reactotron: any, pluginConfig: PluginConfig, onReduxStoreCreation: (func: () => void) => void) {
67
const subscriptionsHandler = createSubscriptionsHandler(reactotron, onReduxStoreCreation)

src/customDispatch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { PluginConfig } from "./pluginConfig"
2+
13
export default function createCustomDispatch(
24
reactotron: any,
35
store: { dispatch: Function },

src/enhancer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import reactotronReducer from "./reducer"
22
import createCustomDispatch from "./customDispatch"
3+
import { PluginConfig } from "./pluginConfig"
34

45
export default function createEnhancer(
56
reactotron: any,

src/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { StoreEnhancer } from 'redux';
2+
13
import createCommandHander from "./commandHandler"
24
import createSendAction from "./sendAction"
35
import createEnhancer from "./enhancer"
46
import { DEFAULT_REPLACER_TYPE } from "./reducer"
7+
import { PluginConfig } from "./pluginConfig"
58

69
function reactotronRedux(pluginConfig: PluginConfig = {}) {
710
const mergedPluginConfig: PluginConfig = {
@@ -32,3 +35,23 @@ function reactotronRedux(pluginConfig: PluginConfig = {}) {
3235
}
3336

3437
export { reactotronRedux }
38+
39+
declare module "reactotron-react-native" {
40+
// eslint-disable-next-line import/export
41+
export interface Reactotron {
42+
/**
43+
* Enhancer creator
44+
*/
45+
createEnhancer: () => StoreEnhancer
46+
}
47+
}
48+
49+
declare module "reactotron-react-js" {
50+
// eslint-disable-next-line import/export
51+
export interface Reactotron {
52+
/**
53+
* Enhancer creator
54+
*/
55+
createEnhancer: () => StoreEnhancer
56+
}
57+
}

src/pluginConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface PluginConfig {
2+
restoreActionType?: string
3+
onBackup?: (state: any) => any
4+
onRestore?: (restoringState: any, reduxState: any) => any
5+
except?: (string | Function | RegExp)[]
6+
isActionImportant?: (action: any) => boolean
7+
}

src/types.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
interface PluginConfig {
2-
restoreActionType?: string
3-
onBackup?: (state: any) => any
4-
onRestore?: (restoringState: any, reduxState: any) => any
5-
except?: (string | Function | RegExp)[]
6-
isActionImportant?: (action: any) => boolean
7-
}
1+
declare module "reactotron-react-native" {}
2+
declare module "reactotron-react-js" {}

tsconfig.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
2-
"compilerOptions": {
3-
"allowJs": false,
4-
"noEmit": true,
5-
"allowSyntheticDefaultImports": true,
6-
"experimentalDecorators": true,
7-
"module": "es2015",
8-
"moduleResolution": "node",
9-
"noImplicitAny": false,
10-
"noImplicitReturns": true,
11-
"noImplicitThis": true,
12-
"noUnusedLocals": true,
13-
"sourceMap": true,
14-
"target": "es2015"
15-
},
16-
"exclude": ["node_modules"],
17-
"include": ["src"]
18-
}
2+
"compilerOptions": {
3+
"allowJs": false,
4+
"declaration": true,
5+
"declarationDir": "dist/types",
6+
"emitDeclarationOnly": true,
7+
"emitDecoratorMetadata": true,
8+
"allowSyntheticDefaultImports": true,
9+
"experimentalDecorators": true,
10+
"module": "es2015",
11+
"moduleResolution": "node",
12+
"noImplicitAny": false,
13+
"noImplicitReturns": true,
14+
"noImplicitThis": true,
15+
"noUnusedLocals": true,
16+
"sourceMap": true,
17+
"target": "es2015"
18+
},
19+
"exclude": ["node_modules"],
20+
"include": ["src"]
21+
}

0 commit comments

Comments
 (0)