diff --git a/extension/examples/counter/components/Counter.js b/extension/examples/counter/components/Counter.js index 08a0fcdb..306ad814 100644 --- a/extension/examples/counter/components/Counter.js +++ b/extension/examples/counter/components/Counter.js @@ -3,13 +3,8 @@ import PropTypes from 'prop-types'; class Counter extends Component { render() { - const { - increment, - autoIncrement, - incrementAsync, - decrement, - counter, - } = this.props; + const { increment, autoIncrement, incrementAsync, decrement, counter } = + this.props; return (
Clicked: {counter} times {' '}
diff --git a/extension/src/app/api/index.js b/extension/src/app/api/index.js
index 3c6ff30d..5c3e94ce 100644
--- a/extension/src/app/api/index.js
+++ b/extension/src/app/api/index.js
@@ -149,12 +149,8 @@ export function toContentScript(message, serializeState, serializeAction) {
message.action = stringify(message.action, serializeAction);
message.payload = stringify(message.payload, serializeState);
} else if (message.type === 'STATE' || message.type === 'PARTIAL_STATE') {
- const {
- actionsById,
- computedStates,
- committedState,
- ...rest
- } = message.payload;
+ const { actionsById, computedStates, committedState, ...rest } =
+ message.payload;
message.payload = rest;
message.actionsById = stringify(actionsById, serializeAction);
message.computedStates = stringify(computedStates, serializeState);
diff --git a/extension/src/browser/extension/inject/pageScript.js b/extension/src/browser/extension/inject/pageScript.js
index 7f3df58f..52046ae6 100644
--- a/extension/src/browser/extension/inject/pageScript.js
+++ b/extension/src/browser/extension/inject/pageScript.js
@@ -448,33 +448,32 @@ window.devToolsExtension.disconnect = (...args) => {
return disconnect.apply(null, args);
};
-const preEnhancer = (instanceId) => (next) => (
- reducer,
- preloadedState,
- enhancer
-) => {
- const store = next(reducer, preloadedState, enhancer);
+const preEnhancer =
+ (instanceId) => (next) => (reducer, preloadedState, enhancer) => {
+ const store = next(reducer, preloadedState, enhancer);
- if (stores[instanceId]) {
- stores[instanceId].initialDispatch = store.dispatch;
- }
+ if (stores[instanceId]) {
+ stores[instanceId].initialDispatch = store.dispatch;
+ }
- return {
- ...store,
- dispatch: (...args) =>
- !window.__REDUX_DEVTOOLS_EXTENSION_LOCKED__ && store.dispatch(...args),
+ return {
+ ...store,
+ dispatch: (...args) =>
+ !window.__REDUX_DEVTOOLS_EXTENSION_LOCKED__ && store.dispatch(...args),
+ };
};
-};
-const extensionCompose = (config) => (...funcs) => {
- return (...args) => {
- const instanceId = generateId(config.instanceId);
- return [preEnhancer(instanceId), ...funcs].reduceRight(
- (composed, f) => f(composed),
- __REDUX_DEVTOOLS_EXTENSION__({ ...config, instanceId })(...args)
- );
+const extensionCompose =
+ (config) =>
+ (...funcs) => {
+ return (...args) => {
+ const instanceId = generateId(config.instanceId);
+ return [preEnhancer(instanceId), ...funcs].reduceRight(
+ (composed, f) => f(composed),
+ __REDUX_DEVTOOLS_EXTENSION__({ ...config, instanceId })(...args)
+ );
+ };
};
-};
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = (...funcs) => {
if (funcs.length === 0) {
diff --git a/extension/src/browser/extension/options/syncOptions.js b/extension/src/browser/extension/options/syncOptions.js
index ac483fe4..04827b5c 100644
--- a/extension/src/browser/extension/options/syncOptions.js
+++ b/extension/src/browser/extension/options/syncOptions.js
@@ -43,8 +43,7 @@ const get = (callback) => {
blacklist: '',
shouldCatchErrors: false,
inject: true,
- urls:
- '^https?://localhost|0\\.0\\.0\\.0:\\d+\n^https?://.+\\.github\\.io',
+ urls: '^https?://localhost|0\\.0\\.0\\.0:\\d+\n^https?://.+\\.github\\.io',
showContextMenus: true,
},
function (items) {
diff --git a/extension/test/app/inject/enhancer.spec.js b/extension/test/app/inject/enhancer.spec.js
index 2ca8824b..14e6cc18 100644
--- a/extension/test/app/inject/enhancer.spec.js
+++ b/extension/test/app/inject/enhancer.spec.js
@@ -155,9 +155,9 @@ describe('Redux enhancer', () => {
state: JSON.stringify({
monitorState: {},
actionsById: {
- '0': { type: 'PERFORM_ACTION', action: { type: '@@INIT' } },
- '1': { type: 'PERFORM_ACTION', action: { type: 'INCREMENT' } },
- '2': { type: 'PERFORM_ACTION', action: { type: 'INCREMENT' } },
+ 0: { type: 'PERFORM_ACTION', action: { type: '@@INIT' } },
+ 1: { type: 'PERFORM_ACTION', action: { type: 'INCREMENT' } },
+ 2: { type: 'PERFORM_ACTION', action: { type: 'INCREMENT' } },
},
nextActionId: 3,
stagedActionIds: [0, 1, 2],
@@ -193,9 +193,8 @@ describe('Redux enhancer', () => {
it('should create the store using old Redux api', async () => {
const message = await listenMessage(() => {
- window.store = window.__REDUX_DEVTOOLS_EXTENSION__()(createStore)(
- counter
- );
+ window.store =
+ window.__REDUX_DEVTOOLS_EXTENSION__()(createStore)(counter);
expect(typeof window.store).toBe('object');
});
expect(message.type).toBe('INIT_INSTANCE');
diff --git a/extension/test/chrome/extension.spec.js b/extension/test/chrome/extension.spec.js
index 0f1845f1..c880c151 100644
--- a/extension/test/chrome/extension.spec.js
+++ b/extension/test/chrome/extension.spec.js
@@ -6,7 +6,8 @@ import { switchMonitorTests, delay } from '../utils/e2e';
const port = 9515;
const path = resolve('build/extension');
const extensionId = 'lmhkpmbekcpmknklioeibfkpmmfibljd';
-const actionsPattern = /^@@INIT(.|\n)+@@reduxReactRouter\/routerDidChange(.|\n)+@@reduxReactRouter\/initRoutes(.|\n)+$/;
+const actionsPattern =
+ /^@@INIT(.|\n)+@@reduxReactRouter\/routerDidChange(.|\n)+@@reduxReactRouter\/initRoutes(.|\n)+$/;
describe('Chrome extension', function () {
beforeAll(async () => {
diff --git a/package.json b/package.json
index 44d1a66f..21f4fff6 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"html-webpack-plugin": "^4.3.0",
"jest": "^26.2.2",
"lerna": "^3.22.1",
- "prettier": "^2.0.5",
+ "prettier": "^2.3.1",
"raw-loader": "^4.0.1",
"rimraf": "^3.0.2",
"style-loader": "^1.2.1",
diff --git a/packages/d3-state-visualizer/src/charts/tree/tree.ts b/packages/d3-state-visualizer/src/charts/tree/tree.ts
index 47ae5176..84d5876b 100644
--- a/packages/d3-state-visualizer/src/charts/tree/tree.ts
+++ b/packages/d3-state-visualizer/src/charts/tree/tree.ts
@@ -214,13 +214,13 @@ export default function (
preserveAspectRatio: 'xMinYMin slice',
};
- if (!((style as unknown) as { [key: string]: Primitive }).width) {
+ if (!(style as unknown as { [key: string]: Primitive }).width) {
attr.width = fullWidth;
}
if (
- !((style as unknown) as { [key: string]: Primitive }).width ||
- !((style as unknown) as { [key: string]: Primitive }).height
+ !(style as unknown as { [key: string]: Primitive }).width ||
+ !(style as unknown as { [key: string]: Primitive }).height
) {
attr.viewBox = `0 0 ${fullWidth} ${fullHeight}`;
}
@@ -230,7 +230,7 @@ export default function (
const vis = root
.append('svg')
.attr(attr)
- .style(({ cursor: '-webkit-grab', ...style } as unknown) as {
+ .style({ cursor: '-webkit-grab', ...style } as unknown as {
[key: string]: Primitive;
})
.call(
@@ -303,10 +303,10 @@ export default function (
: (nextState as NodeWithId);
if (isEmpty(data) || !data.name) {
- data = ({
+ data = {
name: 'error',
message: 'Please provide a state map or a tree structure',
- } as unknown) as NodeWithId;
+ } as unknown as NodeWithId;
}
let nodeIndex = 0;
@@ -366,10 +366,7 @@ export default function (
const node = vis
.selectAll('g.node')
.property('__oldData__', (d: NodeWithId) => d)
- .data(
- nodes,
- (d) => d.id || (d.id = (++nodeIndex as unknown) as string)
- );
+ .data(nodes, (d) => d.id || (d.id = ++nodeIndex as unknown as string));
const nodeEnter = node
.enter()
.append('g')
@@ -550,7 +547,7 @@ export default function (
.transition()
.duration(transitionDuration)
.attr({
- d: (diagonal as unknown) as Primitive,
+ d: diagonal as unknown as Primitive,
});
// transition exiting nodes to the parent's new position
diff --git a/packages/devui/src/Button/styles/common.ts b/packages/devui/src/Button/styles/common.ts
index a58a4c3b..68333c63 100644
--- a/packages/devui/src/Button/styles/common.ts
+++ b/packages/devui/src/Button/styles/common.ts
@@ -192,7 +192,7 @@ export const tooltipStyle = ({
${commonStyle({ theme, mark, size })}
&:before {
- content: "${tooltipTitle}";
+ content: '${tooltipTitle}';
white-space: pre;
color: ${theme.base06};
line-height: 16px;
@@ -200,9 +200,8 @@ export const tooltipStyle = ({
border-radius: 3px;
background: ${theme.base01};
border: 1px solid ${theme.base02};
- box-shadow: 1px 1px 2px -1px ${theme.base02}, 1px 1px 2px 0px ${
- theme.base02
-};
+ box-shadow: 1px 1px 2px -1px ${theme.base02},
+ 1px 1px 2px 0px ${theme.base02};
}
&:after,
@@ -223,18 +222,15 @@ export const tooltipStyle = ({
&:before {
${before(tooltipPosition)}
${getDirection(tooltipPosition)}: 3px;
- ${
- theme.type === 'material'
- ? css`
- animation: ${fadeIn} 500ms;
- `
- : ''
- }
+ ${theme.type === 'material'
+ ? css`
+ animation: ${fadeIn} 500ms;
+ `
+ : ''}
}
- ${
- theme.type !== 'material' &&
- `
+ ${theme.type !== 'material' &&
+ `
&:after {
content: "";
border-style: solid;
@@ -243,8 +239,7 @@ export const tooltipStyle = ({
${after(tooltipPosition, theme.base02)}
${getDirection(tooltipPosition)}: 7px;
}
- `
- }
+ `}
&:hover:after,
&:hover:before {
diff --git a/packages/devui/src/Button/styles/default.ts b/packages/devui/src/Button/styles/default.ts
index c098bcb3..8439f356 100644
--- a/packages/devui/src/Button/styles/default.ts
+++ b/packages/devui/src/Button/styles/default.ts
@@ -21,38 +21,32 @@ export const style = ({
margin: auto 0;
border: 1px solid ${theme.base02};
border-radius: 4px;
- ${
- primary
- ? `
+ ${primary
+ ? `
background-color: ${theme.base05};
color: ${theme.base00};
`
- : `
+ : `
background-color: ${theme.base01};
color: ${theme.base05};
- `
- }
- ${
- disabled
- ? `
+ `}
+ ${disabled
+ ? `
cursor: not-allowed;
opacity: 0.6;
`
- : `
+ : `
cursor: pointer;
- `
- }
+ `}
- ${
- !disabled &&
- `
+ ${!disabled &&
+ `
&:hover,
&:focus {
background-color: ${primary ? theme.base07 : theme.base02};
box-shadow: 1px 1px 2px ${theme.base03};
}
- `
- }
+ `}
&:focus {
border: 1px solid ${theme.base0D};
}
diff --git a/packages/devui/src/Editor/Editor.tsx b/packages/devui/src/Editor/Editor.tsx
index c78ca961..eadc1b2e 100644
--- a/packages/devui/src/Editor/Editor.tsx
+++ b/packages/devui/src/Editor/Editor.tsx
@@ -7,7 +7,7 @@ import { defaultStyle, themedStyle } from './styles';
import { Theme } from '../themes/default';
const EditorContainer = styled.div(
- ('' as unknown) as TemplateStringsArray,
+ '' as unknown as TemplateStringsArray,
({ theme }: { theme: Theme }) =>
theme.scheme === 'default' && theme.light
? defaultStyle
diff --git a/packages/devui/src/Editor/WithTabs.tsx b/packages/devui/src/Editor/WithTabs.tsx
index 60383488..830405a2 100644
--- a/packages/devui/src/Editor/WithTabs.tsx
+++ b/packages/devui/src/Editor/WithTabs.tsx
@@ -33,12 +33,12 @@ export default class WithTabs extends Component extends Component {
/>
> extends PureComponent<
heightBetweenNodesCoeff: 1,
widthBetweenNodesCoeff: 1.3,
tooltipOptions,
- style: (this.getChartStyle() as unknown) as
+ style: this.getChartStyle() as unknown as
| { [key: string]: Primitive }
| undefined,
};
diff --git a/packages/redux-devtools-cli/src/index.ts b/packages/redux-devtools-cli/src/index.ts
index 4b042f89..2421ec6e 100644
--- a/packages/redux-devtools-cli/src/index.ts
+++ b/packages/redux-devtools-cli/src/index.ts
@@ -12,9 +12,7 @@ export interface ExtendedOptions extends Options {
allowClientPublish: boolean;
}
-export default function (argv: {
- [arg: string]: any;
-}): Promise<{
+export default function (argv: { [arg: string]: any }): Promise<{
portAlreadyUsed?: boolean;
on: (status: 'ready', cb: () => void) => void;
}> {
diff --git a/packages/redux-devtools-cli/test/integration.spec.ts b/packages/redux-devtools-cli/test/integration.spec.ts
index c30b4173..f508ff17 100644
--- a/packages/redux-devtools-cli/test/integration.spec.ts
+++ b/packages/redux-devtools-cli/test/integration.spec.ts
@@ -73,19 +73,20 @@ describe('Server', function () {
});
it('should login', function () {
- socket.emit('login', 'master', function (
- error: Error | undefined,
- channelName: string
- ) {
- if (error) {
- /* eslint-disable-next-line no-console */
- console.log(error);
- return;
+ socket.emit(
+ 'login',
+ 'master',
+ function (error: Error | undefined, channelName: string) {
+ if (error) {
+ /* eslint-disable-next-line no-console */
+ console.log(error);
+ return;
+ }
+ expect(channelName).toBe('respond');
+ channel = socket.subscribe(channelName);
+ expect(channel.SUBSCRIBED).toBe('subscribed');
}
- expect(channelName).toBe('respond');
- channel = socket.subscribe(channelName);
- expect(channel.SUBSCRIBED).toBe('subscribed');
- });
+ );
});
it('should send message', function () {
@@ -107,26 +108,27 @@ describe('Server', function () {
id: 'tAmA7H5fclyWhvizAAAi',
};
- socket2.emit('login', '', function (
- error: Error | undefined,
- channelName: string
- ) {
- if (error) {
- /* eslint-disable-next-line no-console */
- console.log(error);
- return;
- }
- expect(channelName).toBe('log');
- const channel2 = socket2.subscribe(channelName);
- expect(channel2.SUBSCRIBED).toBe('subscribed');
- channel2.on('subscribe', function () {
- channel2.watch(function (message) {
- expect(message).toEqual(data);
- done();
+ socket2.emit(
+ 'login',
+ '',
+ function (error: Error | undefined, channelName: string) {
+ if (error) {
+ /* eslint-disable-next-line no-console */
+ console.log(error);
+ return;
+ }
+ expect(channelName).toBe('log');
+ const channel2 = socket2.subscribe(channelName);
+ expect(channel2.SUBSCRIBED).toBe('subscribed');
+ channel2.on('subscribe', function () {
+ channel2.watch(function (message) {
+ expect(message).toEqual(data);
+ done();
+ });
+ socket.emit(channelName, data);
});
- socket.emit(channelName, data);
- });
- });
+ }
+ );
});
});
});
diff --git a/packages/redux-devtools-dock-monitor/src/DockMonitor.tsx b/packages/redux-devtools-dock-monitor/src/DockMonitor.tsx
index 45837b12..ce6649fa 100644
--- a/packages/redux-devtools-dock-monitor/src/DockMonitor.tsx
+++ b/packages/redux-devtools-dock-monitor/src/DockMonitor.tsx
@@ -235,7 +235,7 @@ class DockMonitor> extends Component<
}
}
-export default (DockMonitor as unknown) as React.ComponentType<
+export default DockMonitor as unknown as React.ComponentType<
ExternalProps>(
`(${
child.type.displayName ||
child.type.name ||
- ((child.type as unknown) as string)
+ (child.type as unknown as string)
}) ` +
'does not appear to be a valid Redux DevTools monitor.'
);
diff --git a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/js/index.tsx b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/js/index.tsx
index a3d39ad4..06d7dfb2 100644
--- a/packages/redux-devtools-inspector-monitor-test-tab/demo/src/js/index.tsx
+++ b/packages/redux-devtools-inspector-monitor-test-tab/demo/src/js/index.tsx
@@ -35,16 +35,18 @@ const DevTools = getDevTools(window.location);
const history = createBrowserHistory();
const useDevtoolsExtension =
- !!((window as unknown) as { __REDUX_DEVTOOLS_EXTENSION__: unknown }) &&
+ !!(window as unknown as { __REDUX_DEVTOOLS_EXTENSION__: unknown }) &&
getOptions(window.location).useExtension;
const enhancer = compose(
applyMiddleware(logger, routerMiddleware(history)),
(next: StoreEnhancerStoreCreator) => {
const instrument = useDevtoolsExtension
- ? ((window as unknown) as {
- __REDUX_DEVTOOLS_EXTENSION__(): StoreEnhancer;
- }).__REDUX_DEVTOOLS_EXTENSION__()
+ ? (
+ window as unknown as {
+ __REDUX_DEVTOOLS_EXTENSION__(): StoreEnhancer;
+ }
+ ).__REDUX_DEVTOOLS_EXTENSION__()
: DevTools.instrument();
return instrument(next);
},
diff --git a/packages/redux-devtools-inspector-monitor-test-tab/src/TestGenerator.tsx b/packages/redux-devtools-inspector-monitor-test-tab/src/TestGenerator.tsx
index 040b3eb5..909ccff9 100644
--- a/packages/redux-devtools-inspector-monitor-test-tab/src/TestGenerator.tsx
+++ b/packages/redux-devtools-inspector-monitor-test-tab/src/TestGenerator.tsx
@@ -39,7 +39,7 @@ export function compare(
if (paths.length && paths.indexOf(path) !== -1) return;
paths.push(path);
// eslint-disable-next-line @typescript-eslint/ban-types
- const v = objectPath.get((s2.state as unknown) as object, event.newPath);
+ const v = objectPath.get(s2.state as unknown as object, event.newPath);
curState = v.length;
path += '.length';
} else if (event.type === 'add-item') {
@@ -79,8 +79,8 @@ export default class TestGenerator<
getMethod(action: A) {
let type: string = action.type as string;
if (type[0] === '┗') type = type.substr(1).trim();
- const args = ((action as unknown) as { arguments: unknown[] }).arguments
- ? ((action as unknown) as { arguments: unknown[] }).arguments
+ const args = (action as unknown as { arguments: unknown[] }).arguments
+ ? (action as unknown as { arguments: unknown[] }).arguments
.map((arg) => stringify(arg))
.join(',')
: '';
diff --git a/packages/redux-devtools-inspector-monitor-test-tab/src/index.tsx b/packages/redux-devtools-inspector-monitor-test-tab/src/index.tsx
index 5d6f6aca..67cfda9f 100644
--- a/packages/redux-devtools-inspector-monitor-test-tab/src/index.tsx
+++ b/packages/redux-devtools-inspector-monitor-test-tab/src/index.tsx
@@ -66,10 +66,8 @@ export default class TestTab> extends Component<
};
handleSubmit = ({ formData: template }: { formData: Template }) => {
- const {
- templates = getDefaultTemplates(),
- selected = 0,
- } = this.getPersistedState();
+ const { templates = getDefaultTemplates(), selected = 0 } =
+ this.getPersistedState();
if (this.state.dialogStatus === 'Add') {
this.updateState({
selected: templates.length,
@@ -86,10 +84,8 @@ export default class TestTab> extends Component<
};
handleRemove = () => {
- const {
- templates = getDefaultTemplates(),
- selected = 0,
- } = this.getPersistedState();
+ const { templates = getDefaultTemplates(), selected = 0 } =
+ this.getPersistedState();
this.updateState({
selected: 0,
templates:
@@ -111,9 +107,11 @@ export default class TestTab> extends Component<
updateState = (newState: TestGeneratorMonitorState) => {
this.props.updateMonitorState({
testGenerator: {
- ...(this.props.monitorState as {
- testGenerator?: TestGeneratorMonitorState;
- }).testGenerator,
+ ...(
+ this.props.monitorState as {
+ testGenerator?: TestGeneratorMonitorState;
+ }
+ ).testGenerator,
...newState,
},
} as Partial {
const instrument = useDevtoolsExtension
- ? ((window as unknown) as {
- __REDUX_DEVTOOLS_EXTENSION__(): StoreEnhancer;
- }).__REDUX_DEVTOOLS_EXTENSION__()
+ ? (
+ window as unknown as {
+ __REDUX_DEVTOOLS_EXTENSION__(): StoreEnhancer;
+ }
+ ).__REDUX_DEVTOOLS_EXTENSION__()
: DevTools.instrument();
return instrument(next);
},
diff --git a/packages/redux-devtools-inspector-monitor/src/ActionListRow.tsx b/packages/redux-devtools-inspector-monitor/src/ActionListRow.tsx
index 16c17d1d..7f684c28 100644
--- a/packages/redux-devtools-inspector-monitor/src/ActionListRow.tsx
+++ b/packages/redux-devtools-inspector-monitor/src/ActionListRow.tsx
@@ -78,14 +78,12 @@ export default class ActionListRow<
> extends Component<
return (
> {
onSelectTab: (tabName: string) => void;
}
-const ActionPreviewHeader: FunctionComponent> extends PureComponent<
hideMainButtons,
hideActionButtons,
} = this.props;
- const {
- selectedActionId,
- startActionId,
- searchValue,
- tabName,
- } = monitorState;
+ const { selectedActionId, startActionId, searchValue, tabName } =
+ monitorState;
const inspectedPathType =
tabName === 'Action' ? 'inspectedActionPath' : 'inspectedStatePath';
- const {
- themeState,
- isWideLayout,
- action,
- nextState,
- delta,
- error,
- } = this.state;
+ const { themeState, isWideLayout, action, nextState, delta, error } =
+ this.state;
const { base16Theme, styling } = themeState;
return (
@@ -467,7 +457,7 @@ class DevtoolsInspector> extends PureComponent<
};
}
-export default (DevtoolsInspector as unknown) as React.ComponentType<
+export default DevtoolsInspector as unknown as React.ComponentType<
ExternalProps) {
liftedStore.replaceReducer(
- (liftReducer(
- (nextReducer as unknown) as Reducer
- ) as unknown) as Reducer<
+ liftReducer(
+ nextReducer as unknown as Reducer
+ ) as unknown as Reducer<
LiftedState & NextStateExt,
LiftedAction
>
@@ -946,7 +946,7 @@ export function unliftStore<
},
};
},
- } as unknown) as Store &
+ } as unknown as Store &
NextExt & {
liftedStore: Store<
LiftedState & NextStateExt,
@@ -986,8 +986,8 @@ export default function instrument<
MonitorState = null,
MonitorAction extends Action>(
- reducer: Reducer,
- initialState?: PreloadedState
- ) => {
- function liftReducer(r: Reducer) {
- if (typeof r !== 'function') {
- if (r && typeof (r as { default: unknown }).default === 'function') {
- throw new Error(
- 'Expected the reducer to be a function. ' +
- 'Instead got an object with a "default" field. ' +
- 'Did you pass a module instead of the default export? ' +
- 'Try passing require(...).default instead.'
- );
+ createStore: StoreEnhancerStoreCreator>(
+ reducer: Reducer,
+ initialState?: PreloadedState
+ ) => {
+ function liftReducer(r: Reducer) {
+ if (typeof r !== 'function') {
+ if (r && typeof (r as { default: unknown }).default === 'function') {
+ throw new Error(
+ 'Expected the reducer to be a function. ' +
+ 'Instead got an object with a "default" field. ' +
+ 'Did you pass a module instead of the default export? ' +
+ 'Try passing require(...).default instead.'
+ );
+ }
+ throw new Error('Expected the reducer to be a function.');
}
- throw new Error('Expected the reducer to be a function.');
+ return liftReducerWith(
+ r,
+ initialState,
+ monitorReducer,
+ options as unknown as Options
+ );
}
- return liftReducerWith(
- r,
- initialState,
- monitorReducer,
- (options as unknown) as Options
- );
- }
- const liftedStore = createStore(liftReducer(reducer));
- if (
- (liftedStore as Store<
- LiftedState & NextStateExt,
- LiftedAction
- > &
- NextExt & {
- liftedStore: Store<
- LiftedState,
+ const liftedStore = createStore(liftReducer(reducer));
+ if (
+ (
+ liftedStore as Store<
+ LiftedState & NextStateExt,
LiftedAction
- >;
- }).liftedStore
- ) {
- throw new Error(
- 'DevTools instrumentation should not be applied more than once. ' +
- 'Check your store configuration.'
- );
- }
+ > &
+ NextExt & {
+ liftedStore: Store<
+ LiftedState,
+ LiftedAction
+ >;
+ }
+ ).liftedStore
+ ) {
+ throw new Error(
+ 'DevTools instrumentation should not be applied more than once. ' +
+ 'Check your store configuration.'
+ );
+ }
- return unliftStore<
- S,
- A,
- MonitorState,
- MonitorAction,
- NextExt,
- NextStateExt
- >(
- liftedStore,
- liftReducer,
- (options as unknown) as Options
- );
- };
+ return unliftStore<
+ S,
+ A,
+ MonitorState,
+ MonitorAction,
+ NextExt,
+ NextStateExt
+ >(
+ liftedStore,
+ liftReducer,
+ options as unknown as Options
+ );
+ };
}
diff --git a/packages/redux-devtools-instrument/test/instrument.spec.ts b/packages/redux-devtools-instrument/test/instrument.spec.ts
index 935ab43e..6db96870 100644
--- a/packages/redux-devtools-instrument/test/instrument.spec.ts
+++ b/packages/redux-devtools-instrument/test/instrument.spec.ts
@@ -33,7 +33,7 @@ function counterWithBug(state = 0, action: CounterWithBugAction) {
// @ts-ignore
return mistake - 1;
case 'SET_UNDEFINED':
- return (undefined as unknown) as number;
+ return undefined as unknown as number;
default:
return state;
}
@@ -48,7 +48,7 @@ function counterWithAnotherBug(state = 0, action: CounterWithBugAction) {
case 'INCREMENT':
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
- return ((mistake as unknown) as number) + 1;
+ return (mistake as unknown as number) + 1;
case 'DECREMENT':
return state - 1;
case 'SET_UNDEFINED':
@@ -108,7 +108,7 @@ describe('instrument', () => {
let lastValue;
// let calls = 0;
- from((store as unknown) as Observable> extends PureComponent<
}
}
-export default (LogMonitor as unknown) as React.ComponentType<
+export default LogMonitor as unknown as React.ComponentType<
ExternalProps> // eslint-disable-next-line @typescript-eslint/ban-types
+interface SliderMonitorProps> // eslint-disable-next-line @typescript-eslint/ban-types
extends LiftedState {
// eslint-disable-next-line @typescript-eslint/ban-types
dispatch: Dispatch> extends (PureComponent ||
}
}
-export default (SliderMonitor as unknown) as React.ComponentType<
+export default SliderMonitor as unknown as React.ComponentType<
ExternalProps)
+ !(props.store as unknown as EnhancedStore)
.liftedStore
) {
logError('NoLiftedStore');
@@ -145,11 +145,13 @@ export default function createDevTools<
return (
>(
- reducer: Reducer,
- initialState?: PreloadedState
- ) => {
- const key = `redux-dev-session-${sessionId}`;
+ return (next) =>
+ >(
+ reducer: Reducer,
+ initialState?: PreloadedState
+ ) => {
+ const key = `redux-dev-session-${sessionId}`;
- let finalInitialState;
- try {
- const json = localStorage.getItem(key);
- if (json) {
- finalInitialState = deserialize(JSON.parse(json)) || initialState;
- next(reducer, initialState);
- }
- } catch (e) {
- console.warn('Could not read debug session from localStorage:', e); // eslint-disable-line no-console
+ let finalInitialState;
try {
- localStorage.removeItem(key);
- } finally {
- finalInitialState = undefined;
- }
- }
-
- const store = next(
- reducer,
- finalInitialState as PreloadedState | undefined
- );
-
- return {
- ...store,
- dispatch | undefined
+ );
+
+ return {
+ ...store,
+ dispatch