fix(extension): fix types (#822)

This commit is contained in:
Nathan Bierema 2021-08-30 04:54:35 +00:00 committed by GitHub
parent 95fe2bb42e
commit a640e7345a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 24 deletions

View File

@ -1,23 +1,46 @@
import { combineReducers, Reducer } from 'redux'; import { combineReducers, Reducer } from 'redux';
import instances from '@redux-devtools/app/lib/reducers/instances'; import instances, {
import monitor from '@redux-devtools/app/lib/reducers/monitor'; InstancesState,
import notification from '@redux-devtools/app/lib/reducers/notification'; } from '@redux-devtools/app/lib/reducers/instances';
import reports from '@redux-devtools/app/lib/reducers/reports'; import monitor, {
import section from '@redux-devtools/app/lib/reducers/section'; MonitorState,
import theme from '@redux-devtools/app/lib/reducers/theme'; } from '@redux-devtools/app/lib/reducers/monitor';
import connection from '@redux-devtools/app/lib/reducers/connection'; import notification, {
import { StoreState } from '@redux-devtools/app/lib/reducers'; 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'; import { StoreActionWithTogglePersist } from '../../stores/windowStore';
const rootReducer: Reducer<StoreState, StoreActionWithTogglePersist> = export interface StoreStateWithoutSocket {
combineReducers<StoreState>({ readonly section: SectionState;
instances, readonly theme: ThemeState;
monitor, readonly connection: ConnectionState;
reports, readonly monitor: MonitorState;
notification, readonly instances: InstancesState;
section, readonly reports: ReportsState;
theme, readonly notification: NotificationState;
connection, }
});
const rootReducer: Reducer<
StoreStateWithoutSocket,
StoreActionWithTogglePersist
> = combineReducers<StoreStateWithoutSocket>({
instances,
monitor,
reports,
notification,
section,
theme,
connection,
});
export default rootReducer; export default rootReducer;

View File

@ -1,4 +1,4 @@
import openDevToolsWindow from './openWindow'; import openDevToolsWindow, { DevToolsPosition } from './openWindow';
export function createMenu() { export function createMenu() {
const menus = [ const menus = [
@ -33,5 +33,5 @@ export function removeMenu() {
} }
chrome.contextMenus.onClicked.addListener(({ menuItemId }) => { chrome.contextMenus.onClicked.addListener(({ menuItemId }) => {
openDevToolsWindow(menuItemId); openDevToolsWindow(menuItemId as DevToolsPosition);
}); });

View File

@ -11,6 +11,7 @@ import { Action, PreloadedState, Store } from 'redux';
import { StoreState } from '@redux-devtools/app/lib/reducers'; import { StoreState } from '@redux-devtools/app/lib/reducers';
import { PanelMessage } from '../../../app/middlewares/api'; import { PanelMessage } from '../../../app/middlewares/api';
import { StoreActionWithTogglePersist } from '../../../app/stores/windowStore'; import { StoreActionWithTogglePersist } from '../../../app/stores/windowStore';
import { StoreStateWithoutSocket } from '../../../app/reducers/panel';
const position = location.hash; const position = location.hash;
const messageStyle: CSSProperties = { const messageStyle: CSSProperties = {
@ -20,7 +21,9 @@ const messageStyle: CSSProperties = {
}; };
let rendered: boolean | undefined; let rendered: boolean | undefined;
let store: Store<StoreState, StoreActionWithTogglePersist> | undefined; let store:
| Store<StoreStateWithoutSocket, StoreActionWithTogglePersist>
| undefined;
let bgConnection: chrome.runtime.Port; let bgConnection: chrome.runtime.Port;
let naTimeout: NodeJS.Timeout; let naTimeout: NodeJS.Timeout;
let preloadedState: PreloadedState<StoreState>; let preloadedState: PreloadedState<StoreState>;

View File

@ -1,6 +1,7 @@
import path from 'path'; import path from 'path';
import webpack from 'webpack'; import webpack from 'webpack';
import CopyPlugin from 'copy-webpack-plugin'; import CopyPlugin from 'copy-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
const extpath = path.join(__dirname, '../src/browser/extension/'); const extpath = path.join(__dirname, '../src/browser/extension/');
const mock = `${extpath}chromeAPIMock`; const mock = `${extpath}chromeAPIMock`;
@ -31,7 +32,15 @@ const baseConfig = (params) => ({
}, },
plugins: [ plugins: [
new webpack.DefinePlugin(params.globals), new webpack.DefinePlugin(params.globals),
...(params.plugins ? params.plugins : []), ...(params.plugins
? params.plugins
: [
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: 'tsconfig.json',
},
}),
]),
].concat( ].concat(
params.copy params.copy
? new CopyPlugin({ ? new CopyPlugin({

View File

@ -9,6 +9,14 @@ module.exports = {
project: ['./tsconfig.json'], 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'], files: ['test/*.ts', 'test/*.tsx'],
extends: '../../eslintrc.ts.react.jest.base.json', extends: '../../eslintrc.ts.react.jest.base.json',

View File

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.react.base.json",
"include": ["demo", "src"]
}

View File

@ -3,5 +3,5 @@
"compilerOptions": { "compilerOptions": {
"outDir": "lib" "outDir": "lib"
}, },
"include": ["demo", "src"] "include": ["src"]
} }

View File

@ -65,7 +65,7 @@ module.exports = (env: { development?: boolean; platform?: string } = {}) => ({
}), }),
new ForkTsCheckerWebpackPlugin({ new ForkTsCheckerWebpackPlugin({
typescript: { typescript: {
configFile: 'tsconfig.json', configFile: 'tsconfig.demo.json',
}, },
}), }),
], ],