From 7bd8342fb262905e514accf400b9f30a75953812 Mon Sep 17 00:00:00 2001 From: Jakob Langdal Date: Mon, 27 Jun 2022 07:28:26 +0000 Subject: [PATCH 1/6] Enable strict mode --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index f27266bd..c57976d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, - "strict": false, + "strict": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, From d891b3bdf347e92935c290808707e11e7bcc7e27 Mon Sep 17 00:00:00 2001 From: Jakob Langdal Date: Mon, 27 Jun 2022 07:41:16 +0000 Subject: [PATCH 2/6] Fix migrations --- utility/migration/migration.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utility/migration/migration.ts b/utility/migration/migration.ts index aa5d44aa..8aeee315 100644 --- a/utility/migration/migration.ts +++ b/utility/migration/migration.ts @@ -43,7 +43,7 @@ const bumpVersion = (json: any, version: string): any => { const convertTo3 = (json: any): any => { return { ...json, - valueVariables: json.valueVariables.map(v => { + valueVariables: json.valueVariables.map((v: any) => { return { name: v.name, description: v.description, @@ -78,7 +78,11 @@ const convertTo5 = (json: ExperimentType): ExperimentType => { }, ], dataPoints: json.dataPoints.map(dps => - dps.map(dp => (dp.name === 'score' ? { ...dp, value: dp.value[0] } : dp)) + dps.map(dp => + dp.name === 'score' && Array.isArray(dp.value) + ? { ...dp, value: dp.value[0] } + : dp + ) ), } } From 006af346c7deba7fc766f81f4eee3fce8e6530f8 Mon Sep 17 00:00:00 2001 From: Jakob Langdal Date: Mon, 27 Jun 2022 07:43:04 +0000 Subject: [PATCH 3/6] WIP reducers --- reducers/reducers.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reducers/reducers.test.ts b/reducers/reducers.test.ts index 082f0e6a..84656443 100644 --- a/reducers/reducers.test.ts +++ b/reducers/reducers.test.ts @@ -36,6 +36,7 @@ describe('experiment reducer', () => { max: 200, }, ], + scoreVariables: [], optimizerConfig: { baseEstimator: 'GP', acqFunc: 'gp_hedge', @@ -83,6 +84,7 @@ describe('experiment reducer', () => { max: 201, }, ], + scoreVariables: [], optimizerConfig: { baseEstimator: 'GP', acqFunc: 'gp_hedge', From dc36b76695173bd8c59e4719667b9dc3e4df6d3d Mon Sep 17 00:00:00 2001 From: Jakob Langdal Date: Mon, 27 Jun 2022 10:20:03 +0000 Subject: [PATCH 4/6] WIP --- components/editable-table/editable-table-cell.tsx | 2 +- hooks/useLocalStorageReducer.ts | 2 +- reducers/global-reducer.test.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/editable-table/editable-table-cell.tsx b/components/editable-table/editable-table-cell.tsx index bac37b00..cca75429 100644 --- a/components/editable-table/editable-table-cell.tsx +++ b/components/editable-table/editable-table-cell.tsx @@ -33,7 +33,7 @@ export function EditableTableCell({ size="small" value={value} onChange={(e: ChangeEvent) => - onChange('' + e.target.value) + onChange?.('' + e.target.value) } /> ) diff --git a/hooks/useLocalStorageReducer.ts b/hooks/useLocalStorageReducer.ts index eacc1b18..d8e73d58 100644 --- a/hooks/useLocalStorageReducer.ts +++ b/hooks/useLocalStorageReducer.ts @@ -22,7 +22,7 @@ export const useLocalStorageReducer = ( reducer: (state: S, action: A) => S, initialState: S, localStorageKey: string = 'rootState', - transform = x => x + transform = (x: S) => x ) => { const localStorageReducer = (state: S, action: A) => { const newState = reducer(state, action) diff --git a/reducers/global-reducer.test.ts b/reducers/global-reducer.test.ts index 519a4038..fc0fd79d 100644 --- a/reducers/global-reducer.test.ts +++ b/reducers/global-reducer.test.ts @@ -8,6 +8,7 @@ const initState: State = { dataPointsNewestFirst: false, showJsonEditor: false, uiSizes: [{ key: 'plots', value: 12 }], + focus: 'legacy', } describe('storeExperimentId', () => { From 033ab1ef690cfc1d793400bd7f487e691ab192c9 Mon Sep 17 00:00:00 2001 From: Jakob Langdal Date: Mon, 27 Jun 2022 18:54:23 +0000 Subject: [PATCH 5/6] Fix TS strict issues --- .gitignore | 1 + openapi/apis/DefaultApi.ts | 1 + openapi/models/Experiment.ts | 1 + openapi/models/ExperimentData.ts | 1 + openapi/models/ExperimentOptimizerConfig.ts | 1 + .../models/ExperimentOptimizerConfigSpace.ts | 1 + openapi/models/ModelError.ts | 1 + openapi/models/Result.ts | 1 + openapi/models/ResultPlots.ts | 1 + openapi/models/ResultResult.ts | 1 + openapi/models/ResultResultModels.ts | 1 + package.json | 1 + .../editable-table/editable-table-cell.tsx | 5 +- .../experiment/tabbed-experiment.tsx | 4 +- src/components/home/home.tsx | 14 +- .../input-model/categorical-variable.tsx | 8 +- src/components/json-editor/json-editor.tsx | 5 +- src/components/layout/layout.tsx | 10 +- src/components/plots/pareto-front-plot.tsx | 36 +- src/components/result-data/result-data.tsx | 9 +- src/components/upload-csv-button.tsx | 30 +- src/context/experiment-context.test.tsx | 13 +- src/context/experiment-context.tsx | 29 +- src/context/global-context.tsx | 6 +- src/reducers/experiment-reducers.ts | 8 +- src/reducers/reducers.ts | 5 +- src/store.ts | 2 +- src/types/common.ts | 2 +- src/utility/index.ts | 12 + tsconfig.json | 3 +- yarn.lock | 1868 ++++++++--------- 31 files changed, 1052 insertions(+), 1029 deletions(-) create mode 100644 src/utility/index.ts diff --git a/.gitignore b/.gitignore index e1227a04..598ed0ae 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ db # local files used in development /specification.yml .vscode +tsconfig.tsbuildinfo diff --git a/openapi/apis/DefaultApi.ts b/openapi/apis/DefaultApi.ts index 91010e92..ea60cc67 100644 --- a/openapi/apis/DefaultApi.ts +++ b/openapi/apis/DefaultApi.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/Experiment.ts b/openapi/models/Experiment.ts index a5a878bd..5df470bb 100644 --- a/openapi/models/Experiment.ts +++ b/openapi/models/Experiment.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ExperimentData.ts b/openapi/models/ExperimentData.ts index 9449d518..88177ed7 100644 --- a/openapi/models/ExperimentData.ts +++ b/openapi/models/ExperimentData.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ExperimentOptimizerConfig.ts b/openapi/models/ExperimentOptimizerConfig.ts index d8dae37a..e7a83899 100644 --- a/openapi/models/ExperimentOptimizerConfig.ts +++ b/openapi/models/ExperimentOptimizerConfig.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ExperimentOptimizerConfigSpace.ts b/openapi/models/ExperimentOptimizerConfigSpace.ts index ada8bb34..6f7a1f4f 100644 --- a/openapi/models/ExperimentOptimizerConfigSpace.ts +++ b/openapi/models/ExperimentOptimizerConfigSpace.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ModelError.ts b/openapi/models/ModelError.ts index 1f12a211..72133ae0 100644 --- a/openapi/models/ModelError.ts +++ b/openapi/models/ModelError.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/Result.ts b/openapi/models/Result.ts index 2b308884..7613c7dd 100644 --- a/openapi/models/Result.ts +++ b/openapi/models/Result.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ResultPlots.ts b/openapi/models/ResultPlots.ts index 832e7c0e..8ed415ce 100644 --- a/openapi/models/ResultPlots.ts +++ b/openapi/models/ResultPlots.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ResultResult.ts b/openapi/models/ResultResult.ts index fcefa6ab..d1b2d459 100644 --- a/openapi/models/ResultResult.ts +++ b/openapi/models/ResultResult.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/openapi/models/ResultResultModels.ts b/openapi/models/ResultResultModels.ts index ef58666c..c3cbc736 100644 --- a/openapi/models/ResultResultModels.ts +++ b/openapi/models/ResultResultModels.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* tslint:disable */ /* eslint-disable */ /** diff --git a/package.json b/package.json index 028e1910..fa4c9fa2 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@types/node": "^18.0.0", "@types/react": "^18.0.14", "@types/rimraf": "^3.0.0", + "@types/uuid": "^8.3.4", "eslint": "8.18.0", "eslint-config-next": "12.1.6", "git-revision-webpack-plugin": "^5.0.0", diff --git a/src/components/editable-table/editable-table-cell.tsx b/src/components/editable-table/editable-table-cell.tsx index 99dc6898..0704f89e 100644 --- a/src/components/editable-table/editable-table-cell.tsx +++ b/src/components/editable-table/editable-table-cell.tsx @@ -2,6 +2,7 @@ import { FormControl, MenuItem, Select, + SelectChangeEvent, TableCell, TextField, Tooltip, @@ -46,9 +47,7 @@ export function EditableTableCell({