From 36e0497404d011d679cc086daa0ea15311d121d3 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 17 Sep 2024 16:25:57 -0500 Subject: [PATCH 1/5] Upgraded TypeScript to 5.6.2 (#2222) --- package-lock.json | 63 +++++++++---------- package.json | 2 +- packages/components/src/BulkActionBar.tsx | 2 +- .../src/context-actions/ContextActionUtils.ts | 2 +- .../src/spectrum/utils/itemUtils.ts | 4 +- .../src/panels/IrisGridPanel.tsx | 5 +- packages/iris-grid/src/IrisGrid.tsx | 3 +- .../src/sidebar/CustomColumnBuilder.tsx | 4 +- packages/plugin/src/PluginTypes.ts | 2 +- .../redux/src/reducers/common/mergeReducer.ts | 2 +- .../src/reducers/common/replaceByIdReducer.ts | 2 +- .../src/reducers/common/replaceReducer.ts | 2 +- packages/utils/src/EventTargetShimUtils.ts | 2 + 13 files changed, 48 insertions(+), 47 deletions(-) diff --git a/package-lock.json b/package-lock.json index 885a8644f..0d3528470 100644 --- a/package-lock.json +++ b/package-lock.json @@ -128,7 +128,7 @@ "sass": "^1.39.0", "source-map-explorer": "^2.5.2", "stylelint": "^14.5.1", - "typescript": "~4.9.4", + "typescript": "~5.6.2", "vite": "^5.4.2" }, "engines": { @@ -3994,21 +3994,6 @@ "node": ">=8" } }, - "node_modules/@lerna/create/node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "dev": true, - "optional": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/@lerna/create/node_modules/uuid": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", @@ -28138,15 +28123,15 @@ } }, "node_modules/typescript": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", - "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/ua-parser-js": { @@ -29271,6 +29256,7 @@ "lodash.throttle": "^4.1.1" }, "devDependencies": { + "@deephaven/test-utils": "file:../test-utils", "react": "^17.x", "react-dom": "^17.x", "react-redux": "^7.x", @@ -29346,6 +29332,7 @@ "js-cookie": "^3.0.5" }, "devDependencies": { + "@deephaven/test-utils": "file:../test-utils", "@types/react": "^17.0.2" }, "engines": { @@ -29396,6 +29383,7 @@ "devDependencies": { "@deephaven/jsapi-shim": "file:../jsapi-shim", "@deephaven/mocks": "file:../mocks", + "@deephaven/test-utils": "file:../test-utils", "@types/plotly.js": "^2.12.11" }, "engines": { @@ -29488,6 +29476,7 @@ "@deephaven/mocks": "file:../mocks", "@deephaven/prettier-config": "file:../prettier-config", "@deephaven/stylelint-config": "file:../stylelint-config", + "@deephaven/test-utils": "file:../test-utils", "autoprefixer": "^10.4.8" } }, @@ -29600,7 +29589,8 @@ }, "devDependencies": { "@deephaven/jsapi-shim": "file:../jsapi-shim", - "@deephaven/mocks": "file:../mocks" + "@deephaven/mocks": "file:../mocks", + "@deephaven/test-utils": "file:../test-utils" }, "engines": { "node": ">=16" @@ -29629,6 +29619,7 @@ }, "devDependencies": { "@deephaven/mocks": "file:../mocks", + "@deephaven/test-utils": "file:../test-utils", "@types/lodash.ismatch": "^4.4.0" }, "engines": { @@ -29684,7 +29675,8 @@ }, "devDependencies": { "@deephaven/jsapi-shim": "file:../jsapi-shim", - "@deephaven/mocks": "file:../mocks" + "@deephaven/mocks": "file:../mocks", + "@deephaven/test-utils": "file:../test-utils" }, "engines": { "node": ">=16" @@ -30148,7 +30140,8 @@ "prop-types": "^15.7.2" }, "devDependencies": { - "@deephaven/mocks": "file:../mocks" + "@deephaven/mocks": "file:../mocks", + "@deephaven/test-utils": "file:../test-utils" }, "engines": { "node": ">=16" @@ -30284,6 +30277,7 @@ "@deephaven/utils": "file:../utils" }, "devDependencies": { + "@deephaven/test-utils": "file:../test-utils", "react": "^17.x" }, "engines": { @@ -31834,6 +31828,7 @@ "@deephaven/react-hooks": "file:../react-hooks", "@deephaven/redux": "file:../redux", "@deephaven/storage": "file:../storage", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@fontsource/fira-mono": "5.0.13", "@fontsource/fira-sans": "5.0.20", @@ -31858,6 +31853,7 @@ "@deephaven/jsapi-utils": "file:../jsapi-utils", "@deephaven/log": "file:../log", "@deephaven/redux": "file:../redux", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@types/react": "^17.0.2", "classnames": "^2.3.1", @@ -31888,6 +31884,7 @@ "@deephaven/log": "file:../log", "@deephaven/mocks": "file:../mocks", "@deephaven/react-hooks": "file:../react-hooks", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@types/plotly.js": "^2.12.11", "buffer": "^6.0.3", @@ -31944,6 +31941,7 @@ "@deephaven/redux": "file:../redux", "@deephaven/storage": "file:../storage", "@deephaven/stylelint-config": "file:../stylelint-config", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/react-fontawesome": "^0.2.0", @@ -32033,6 +32031,7 @@ "@deephaven/mocks": "file:../mocks", "@deephaven/react-hooks": "file:../react-hooks", "@deephaven/storage": "file:../storage", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@fortawesome/react-fontawesome": "^0.2.0", "classnames": "^2.3.1", @@ -32058,6 +32057,7 @@ "@deephaven/mocks": "file:../mocks", "@deephaven/react-hooks": "file:../react-hooks", "@deephaven/redux": "file:../redux", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@types/lodash.ismatch": "^4.4.0", "fast-deep-equal": "^3.1.3", @@ -32103,6 +32103,7 @@ "@deephaven/react-hooks": "file:../react-hooks", "@deephaven/redux": "file:../redux", "@deephaven/storage": "file:../storage", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@fortawesome/react-fontawesome": "^0.2.0", "classnames": "^2.3.1", @@ -32441,6 +32442,7 @@ "@deephaven/log": "file:../log", "@deephaven/mocks": "file:../mocks", "@deephaven/storage": "file:../storage", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/react-fontawesome": "^0.2.0", @@ -32531,6 +32533,7 @@ "@deephaven/jsapi-types": "^1.0.0-dev0.34.0", "@deephaven/log": "file:../log", "@deephaven/react-hooks": "file:../react-hooks", + "@deephaven/test-utils": "file:../test-utils", "@deephaven/utils": "file:../utils", "react": "^17.x" } @@ -33909,14 +33912,6 @@ "has-flag": "^4.0.0" } }, - "typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "dev": true, - "optional": true, - "peer": true - }, "uuid": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", @@ -51640,9 +51635,9 @@ } }, "typescript": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", - "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==" + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==" }, "ua-parser-js": { "version": "0.7.33", diff --git a/package.json b/package.json index 64ec8e2f8..f872c2890 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "sass": "^1.39.0", "source-map-explorer": "^2.5.2", "stylelint": "^14.5.1", - "typescript": "~4.9.4", + "typescript": "~5.6.2", "vite": "^5.4.2" }, "prettier": "@deephaven/prettier-config", diff --git a/packages/components/src/BulkActionBar.tsx b/packages/components/src/BulkActionBar.tsx index df6d03551..f59d9097e 100644 --- a/packages/components/src/BulkActionBar.tsx +++ b/packages/components/src/BulkActionBar.tsx @@ -22,7 +22,7 @@ export function BulkActionBar({ selectedItemCount={selectedItemCount} onClearSelection={onClearSelection} > - {/* */} + ); } diff --git a/packages/components/src/context-actions/ContextActionUtils.ts b/packages/components/src/context-actions/ContextActionUtils.ts index 49c187227..06f9b70fd 100644 --- a/packages/components/src/context-actions/ContextActionUtils.ts +++ b/packages/components/src/context-actions/ContextActionUtils.ts @@ -14,7 +14,7 @@ export interface ContextAction { description?: string; action?: (event: Event) => void; actions?: ResolvableContextAction[]; - icon?: IconDefinition | React.ReactElement; + icon?: IconDefinition | React.ReactElement; iconColor?: string; shortcut?: Shortcut; diff --git a/packages/components/src/spectrum/utils/itemUtils.ts b/packages/components/src/spectrum/utils/itemUtils.ts index a0e15bb07..7a8d674db 100644 --- a/packages/components/src/spectrum/utils/itemUtils.ts +++ b/packages/components/src/spectrum/utils/itemUtils.ts @@ -256,7 +256,9 @@ export function isNormalizedItemsWithKeysList< return true; } - return !isItemOrSection(node[0]) && 'key' in node[0]; + return ( + !isItemOrSection(node[0]) && typeof node[0] === 'object' && 'key' in node[0] + ); } /** diff --git a/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx b/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx index 1b68ea5bd..34d0b62fc 100644 --- a/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx +++ b/packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx @@ -62,6 +62,7 @@ import { import { assertNotNull, CancelablePromise, + EventT, PromiseUtils, } from '@deephaven/utils'; import { ResolvableContextAction } from '@deephaven/components'; @@ -703,7 +704,7 @@ export class IrisGridPanel extends PureComponent< } } - handleColumnsChanged(event: Event): void { + handleColumnsChanged(event: EventT): void { const { isModelReady, model, modelQueue } = this.state; if (isModelReady) { this.sendColumnsChange((event as CustomEvent).detail); @@ -713,7 +714,7 @@ export class IrisGridPanel extends PureComponent< } } - handleTableChanged(event: Event): void { + handleTableChanged(event: EventT): void { log.debug('handleTableChanged', event); const { glEventHub } = this.props; const { detail: table } = event as CustomEvent; diff --git a/packages/iris-grid/src/IrisGrid.tsx b/packages/iris-grid/src/IrisGrid.tsx index fb9b1ba1d..3797af516 100644 --- a/packages/iris-grid/src/IrisGrid.tsx +++ b/packages/iris-grid/src/IrisGrid.tsx @@ -88,6 +88,7 @@ import { PromiseUtils, ValidationError, getOrThrow, + type EventT, } from '@deephaven/utils'; import { Type as FilterType, @@ -3103,7 +3104,7 @@ class IrisGrid extends Component { })); } - handleRequestFailed(event: Event): void { + handleRequestFailed(event: EventT): void { const { detail: error } = event as CustomEvent; log.error('request failed:', error); this.stopLoading(); diff --git a/packages/iris-grid/src/sidebar/CustomColumnBuilder.tsx b/packages/iris-grid/src/sidebar/CustomColumnBuilder.tsx index 5f302ca42..0f32fe1fd 100644 --- a/packages/iris-grid/src/sidebar/CustomColumnBuilder.tsx +++ b/packages/iris-grid/src/sidebar/CustomColumnBuilder.tsx @@ -6,7 +6,7 @@ import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Button, DragUtils, LoadingSpinner } from '@deephaven/components'; import { dhNewCircleLargeFilled, vsWarning, vsPass } from '@deephaven/icons'; -import { DbNameValidator } from '@deephaven/utils'; +import { DbNameValidator, EventT } from '@deephaven/utils'; import CustomColumnInput from './CustomColumnInput'; import './CustomColumnBuilder.scss'; import IrisGridModel from '../IrisGridModel'; @@ -211,7 +211,7 @@ class CustomColumnBuilder extends Component< ); } - handleRequestFailed(event: Event): void { + handleRequestFailed(event: EventT): void { const customEvent = event as CustomEvent; const { isCustomColumnApplying } = this.state; if (!isCustomColumnApplying) { diff --git a/packages/plugin/src/PluginTypes.ts b/packages/plugin/src/PluginTypes.ts index 3f63e780e..2d67120d4 100644 --- a/packages/plugin/src/PluginTypes.ts +++ b/packages/plugin/src/PluginTypes.ts @@ -160,7 +160,7 @@ export interface WidgetPlugin extends Plugin { * If a react node is provided (including a string), it will be rendered directly. * If no icon is specified, the default widget icon will be used. */ - icon?: IconDefinition | React.ReactElement; + icon?: IconDefinition | React.ReactElement; } export function isWidgetPlugin(plugin: PluginModule): plugin is WidgetPlugin { diff --git a/packages/redux/src/reducers/common/mergeReducer.ts b/packages/redux/src/reducers/common/mergeReducer.ts index 6136e5659..d32f9141b 100644 --- a/packages/redux/src/reducers/common/mergeReducer.ts +++ b/packages/redux/src/reducers/common/mergeReducer.ts @@ -11,7 +11,7 @@ export default function mergeReducer( initialState: S ): Reducer { return (state = initialState, action?) => { - switch (action.type) { + switch (action?.type) { case type: { const newState = action.payload; if (newState == null) { diff --git a/packages/redux/src/reducers/common/replaceByIdReducer.ts b/packages/redux/src/reducers/common/replaceByIdReducer.ts index 94f44149b..949f48bbd 100644 --- a/packages/redux/src/reducers/common/replaceByIdReducer.ts +++ b/packages/redux/src/reducers/common/replaceByIdReducer.ts @@ -12,7 +12,7 @@ export default function replaceByIdReducer>( checkIfChanged = true ): Reducer { return (state = initialState, action?) => { - switch (action.type) { + switch (action?.type) { case type: { const { id, payload } = action; if (checkIfChanged && deepEqual({ payload }, { payload: state[id] })) { diff --git a/packages/redux/src/reducers/common/replaceReducer.ts b/packages/redux/src/reducers/common/replaceReducer.ts index 0152c3b76..50c3e6333 100644 --- a/packages/redux/src/reducers/common/replaceReducer.ts +++ b/packages/redux/src/reducers/common/replaceReducer.ts @@ -11,7 +11,7 @@ export default function replaceReducer( initialState: S ): Reducer { return (state = initialState, action?) => { - switch (action.type) { + switch (action?.type) { case type: { return action.payload; } diff --git a/packages/utils/src/EventTargetShimUtils.ts b/packages/utils/src/EventTargetShimUtils.ts index c5a49ac9a..0245eb907 100644 --- a/packages/utils/src/EventTargetShimUtils.ts +++ b/packages/utils/src/EventTargetShimUtils.ts @@ -1,5 +1,7 @@ import type { Event, EventTarget } from 'event-target-shim'; +export type EventT = Event; + /** * A CustomEvent extension which combines the browser CustomEvent and event-target-shim's Event types for type safety * CustomEvent does not have a generic type and augmenting the dom types seemed like not the best idea From e542797e6e83f6d5c3bd17ae44d71f00ca729dc5 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 17 Sep 2024 16:33:28 -0500 Subject: [PATCH 2/5] Fixed type errors (#2222) --- packages/utils/src/EventTargetShimUtils.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/utils/src/EventTargetShimUtils.ts b/packages/utils/src/EventTargetShimUtils.ts index 0245eb907..bdf8209e1 100644 --- a/packages/utils/src/EventTargetShimUtils.ts +++ b/packages/utils/src/EventTargetShimUtils.ts @@ -1,6 +1,9 @@ -import type { Event, EventTarget } from 'event-target-shim'; +import type { + Event as EventT, + EventTarget as EventTargetT, +} from 'event-target-shim'; -export type EventT = Event; +export type { EventT }; /** * A CustomEvent extension which combines the browser CustomEvent and event-target-shim's Event types for type safety @@ -17,13 +20,13 @@ export class EventShimCustomEvent< // https://github.com/babel/babel/issues/12128#issuecomment-702119272 declare type: T; - declare target: EventTarget | null; + declare target: (EventTargetT & EventTarget) | null; - declare srcElement: EventTarget | null; + declare srcElement: (EventTargetT & EventTarget) | null; - declare currentTarget: EventTarget | null; + declare currentTarget: (EventTargetT & EventTarget) | null; - declare composedPath: () => EventTarget[]; + declare composedPath: () => (EventTargetT & EventTarget)[]; // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor(typeArg: T, eventInitDict?: CustomEventInit) { @@ -40,8 +43,8 @@ export type CustomEventMap> = { [T in keyof M]: T extends string ? M[T] extends CustomEvent ? EventShimCustomEvent - : M[T] extends Event - ? Event + : M[T] extends EventT + ? EventT : never : never; }; From ff64ab8b355193ccea7a68e1f6d53c691942fe71 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 17 Sep 2024 16:48:05 -0500 Subject: [PATCH 3/5] Fixing e2e tests (#2222) --- packages/log/src/LogProxy.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/log/src/LogProxy.ts b/packages/log/src/LogProxy.ts index 85315dd6c..795bf3c25 100644 --- a/packages/log/src/LogProxy.ts +++ b/packages/log/src/LogProxy.ts @@ -125,14 +125,20 @@ export class LogProxy { listener: (event: CustomEvent) => void ): void { // The cast as EventListener is a dumb TypeScript issue - this.eventTarget.addEventListener(type, listener as EventListener); + this.eventTarget.addEventListener( + type, + listener as Parameters[1] + ); } removeEventListener( type: LOG_PROXY_TYPE, listener: (event: CustomEvent) => void ): void { - this.eventTarget.removeEventListener(type, listener as EventListener); + this.eventTarget.removeEventListener( + type, + listener as Parameters[1] + ); } } From 288d2bc2f85dd2ec5edfb210b396881ebb0468d1 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 17 Sep 2024 17:06:57 -0500 Subject: [PATCH 4/5] Fixed method name (#2222) --- packages/log/src/LogProxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/log/src/LogProxy.ts b/packages/log/src/LogProxy.ts index 795bf3c25..4cb0b1d21 100644 --- a/packages/log/src/LogProxy.ts +++ b/packages/log/src/LogProxy.ts @@ -137,7 +137,7 @@ export class LogProxy { ): void { this.eventTarget.removeEventListener( type, - listener as Parameters[1] + listener as Parameters[1] ); } } From f969947c3922183211fabedbc03934c806dccae7 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Wed, 18 Sep 2024 13:51:06 -0500 Subject: [PATCH 5/5] Addressed code review comments (#2222) --- packages/components/src/BulkActionBar.tsx | 10 ++++++++-- packages/log/src/LogProxy.ts | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/components/src/BulkActionBar.tsx b/packages/components/src/BulkActionBar.tsx index f59d9097e..123585274 100644 --- a/packages/components/src/BulkActionBar.tsx +++ b/packages/components/src/BulkActionBar.tsx @@ -1,7 +1,13 @@ -import type { StyleProps } from '@react-types/shared'; +import type { ItemElement, StyleProps } from '@react-types/shared'; import { ActionBar } from './spectrum'; import commonStyles from './SpectrumComponent.module.scss'; +// The action bar will still show the item count + a clear selection button +// even if there are no actions. Our only consumer is currently the ACL Editor, +// but group action functionality has not yet been prioritized (see DH-15221). +// For now we'll just pass it an empty action items array. +const noActions: ItemElement[] = []; + export interface BulkActionBarProps { styleProps?: StyleProps; selectedItemCount: 'all' | number; @@ -22,7 +28,7 @@ export function BulkActionBar({ selectedItemCount={selectedItemCount} onClearSelection={onClearSelection} > - + {noActions} ); } diff --git a/packages/log/src/LogProxy.ts b/packages/log/src/LogProxy.ts index 4cb0b1d21..0d6ecc1f5 100644 --- a/packages/log/src/LogProxy.ts +++ b/packages/log/src/LogProxy.ts @@ -124,7 +124,6 @@ export class LogProxy { type: LOG_PROXY_TYPE, listener: (event: CustomEvent) => void ): void { - // The cast as EventListener is a dumb TypeScript issue this.eventTarget.addEventListener( type, listener as Parameters[1]