From a640e7345a99086ced46504a6dd8bd31788bb8e5 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Mon, 30 Aug 2021 04:54:35 +0000 Subject: [PATCH] fix(extension): fix types (#822) --- extension/src/app/reducers/panel/index.ts | 59 +++++++++++++------ .../extension/background/contextMenus.ts | 4 +- .../src/browser/extension/devpanel/index.tsx | 5 +- extension/webpack/base.config.js | 11 +++- packages/redux-devtools-app/.eslintrc.js | 8 +++ .../redux-devtools-app/tsconfig.demo.json | 4 ++ packages/redux-devtools-app/tsconfig.json | 2 +- packages/redux-devtools-app/webpack.config.ts | 2 +- 8 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 packages/redux-devtools-app/tsconfig.demo.json diff --git a/extension/src/app/reducers/panel/index.ts b/extension/src/app/reducers/panel/index.ts index 15d1b8c4..c3829e6b 100644 --- a/extension/src/app/reducers/panel/index.ts +++ b/extension/src/app/reducers/panel/index.ts @@ -1,23 +1,46 @@ import { combineReducers, Reducer } from 'redux'; -import instances from '@redux-devtools/app/lib/reducers/instances'; -import monitor from '@redux-devtools/app/lib/reducers/monitor'; -import notification from '@redux-devtools/app/lib/reducers/notification'; -import reports from '@redux-devtools/app/lib/reducers/reports'; -import section from '@redux-devtools/app/lib/reducers/section'; -import theme from '@redux-devtools/app/lib/reducers/theme'; -import connection from '@redux-devtools/app/lib/reducers/connection'; -import { StoreState } from '@redux-devtools/app/lib/reducers'; +import instances, { + InstancesState, +} from '@redux-devtools/app/lib/reducers/instances'; +import monitor, { + MonitorState, +} from '@redux-devtools/app/lib/reducers/monitor'; +import notification, { + NotificationState, +} from '@redux-devtools/app/lib/reducers/notification'; +import reports, { + ReportsState, +} from '@redux-devtools/app/lib/reducers/reports'; +import section, { + SectionState, +} from '@redux-devtools/app/lib/reducers/section'; +import theme, { ThemeState } from '@redux-devtools/app/lib/reducers/theme'; +import connection, { + ConnectionState, +} from '@redux-devtools/app/lib/reducers/connection'; import { StoreActionWithTogglePersist } from '../../stores/windowStore'; -const rootReducer: Reducer = - combineReducers({ - instances, - monitor, - reports, - notification, - section, - theme, - connection, - }); +export interface StoreStateWithoutSocket { + readonly section: SectionState; + readonly theme: ThemeState; + readonly connection: ConnectionState; + readonly monitor: MonitorState; + readonly instances: InstancesState; + readonly reports: ReportsState; + readonly notification: NotificationState; +} + +const rootReducer: Reducer< + StoreStateWithoutSocket, + StoreActionWithTogglePersist +> = combineReducers({ + instances, + monitor, + reports, + notification, + section, + theme, + connection, +}); export default rootReducer; diff --git a/extension/src/browser/extension/background/contextMenus.ts b/extension/src/browser/extension/background/contextMenus.ts index 070a1a3b..d8a30145 100644 --- a/extension/src/browser/extension/background/contextMenus.ts +++ b/extension/src/browser/extension/background/contextMenus.ts @@ -1,4 +1,4 @@ -import openDevToolsWindow from './openWindow'; +import openDevToolsWindow, { DevToolsPosition } from './openWindow'; export function createMenu() { const menus = [ @@ -33,5 +33,5 @@ export function removeMenu() { } chrome.contextMenus.onClicked.addListener(({ menuItemId }) => { - openDevToolsWindow(menuItemId); + openDevToolsWindow(menuItemId as DevToolsPosition); }); diff --git a/extension/src/browser/extension/devpanel/index.tsx b/extension/src/browser/extension/devpanel/index.tsx index 484e5e38..ab617331 100644 --- a/extension/src/browser/extension/devpanel/index.tsx +++ b/extension/src/browser/extension/devpanel/index.tsx @@ -11,6 +11,7 @@ import { Action, PreloadedState, Store } from 'redux'; import { StoreState } from '@redux-devtools/app/lib/reducers'; import { PanelMessage } from '../../../app/middlewares/api'; import { StoreActionWithTogglePersist } from '../../../app/stores/windowStore'; +import { StoreStateWithoutSocket } from '../../../app/reducers/panel'; const position = location.hash; const messageStyle: CSSProperties = { @@ -20,7 +21,9 @@ const messageStyle: CSSProperties = { }; let rendered: boolean | undefined; -let store: Store | undefined; +let store: + | Store + | undefined; let bgConnection: chrome.runtime.Port; let naTimeout: NodeJS.Timeout; let preloadedState: PreloadedState; diff --git a/extension/webpack/base.config.js b/extension/webpack/base.config.js index f6ce54a5..0fde60d6 100644 --- a/extension/webpack/base.config.js +++ b/extension/webpack/base.config.js @@ -1,6 +1,7 @@ import path from 'path'; import webpack from 'webpack'; import CopyPlugin from 'copy-webpack-plugin'; +import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; const extpath = path.join(__dirname, '../src/browser/extension/'); const mock = `${extpath}chromeAPIMock`; @@ -31,7 +32,15 @@ const baseConfig = (params) => ({ }, plugins: [ new webpack.DefinePlugin(params.globals), - ...(params.plugins ? params.plugins : []), + ...(params.plugins + ? params.plugins + : [ + new ForkTsCheckerWebpackPlugin({ + typescript: { + configFile: 'tsconfig.json', + }, + }), + ]), ].concat( params.copy ? new CopyPlugin({ diff --git a/packages/redux-devtools-app/.eslintrc.js b/packages/redux-devtools-app/.eslintrc.js index ce28cd35..d5331241 100644 --- a/packages/redux-devtools-app/.eslintrc.js +++ b/packages/redux-devtools-app/.eslintrc.js @@ -9,6 +9,14 @@ module.exports = { project: ['./tsconfig.json'], }, }, + { + files: ['demo/*.ts', 'demo/*.tsx'], + extends: '../../eslintrc.ts.react.base.json', + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.demo.json'], + }, + }, { files: ['test/*.ts', 'test/*.tsx'], extends: '../../eslintrc.ts.react.jest.base.json', diff --git a/packages/redux-devtools-app/tsconfig.demo.json b/packages/redux-devtools-app/tsconfig.demo.json new file mode 100644 index 00000000..fe7c960f --- /dev/null +++ b/packages/redux-devtools-app/tsconfig.demo.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.react.base.json", + "include": ["demo", "src"] +} diff --git a/packages/redux-devtools-app/tsconfig.json b/packages/redux-devtools-app/tsconfig.json index b742078e..7b7d1492 100644 --- a/packages/redux-devtools-app/tsconfig.json +++ b/packages/redux-devtools-app/tsconfig.json @@ -3,5 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": ["demo", "src"] + "include": ["src"] } diff --git a/packages/redux-devtools-app/webpack.config.ts b/packages/redux-devtools-app/webpack.config.ts index c419bcc5..7831a152 100644 --- a/packages/redux-devtools-app/webpack.config.ts +++ b/packages/redux-devtools-app/webpack.config.ts @@ -65,7 +65,7 @@ module.exports = (env: { development?: boolean; platform?: string } = {}) => ({ }), new ForkTsCheckerWebpackPlugin({ typescript: { - configFile: 'tsconfig.json', + configFile: 'tsconfig.demo.json', }, }), ],