From 971ccba34d3e75d2bc135fcdf120b5fc475c6843 Mon Sep 17 00:00:00 2001 From: georgecwan Date: Wed, 18 Oct 2023 13:13:04 -0700 Subject: [PATCH 1/6] Enable method-signature-style ESLint rule --- @types/memoizee/index.d.ts | 4 +- .../code-studio/src/settings/ShortcutItem.tsx | 2 +- .../src/settings/ShortcutsSectionContent.tsx | 2 +- .../command-history/CommandHistoryStorage.ts | 18 +- packages/console/src/csv/ZipStreamHelper.ts | 6 +- .../src/panels/FilterSetManager.tsx | 8 +- .../src/panels/IrisGridPanel.test.tsx | 2 +- packages/eslint-config/index.js | 1 + .../file-explorer/src/FileExplorerToolbar.tsx | 6 +- packages/file-explorer/src/FileListItem.tsx | 8 +- packages/file-explorer/src/FileStorage.ts | 22 +- packages/grid/src/ColumnHeaderGroup.ts | 2 +- packages/grid/src/DataBarGridModel.ts | 4 +- packages/grid/src/EditableGridModel.ts | 21 +- packages/grid/src/ExpandableGridModel.ts | 14 +- packages/grid/src/TokenBoxCellRenderer.ts | 4 +- .../src/AdvancedFilterCreatorFilterItem.tsx | 4 +- packages/iris-grid/src/IrisGrid.test.tsx | 3 +- .../VisibilityOrderingGroup.tsx | 8 +- .../VisibilityOrderingItem.tsx | 15 +- .../sortable-tree/SortableTree.tsx | 8 +- .../sortable-tree/SortableTreeInner.tsx | 4 +- .../sortable-tree/TreeItem.tsx | 4 +- packages/jsapi-components/src/TableInput.tsx | 2 +- packages/jsapi-types/src/dh.types.ts | 443 +++++++++--------- packages/plugin/src/PluginTypes.ts | 2 +- packages/redux/src/store.ts | 4 +- packages/storage/src/Storage.ts | 20 +- tests/utils.ts | 7 +- 29 files changed, 329 insertions(+), 319 deletions(-) diff --git a/@types/memoizee/index.d.ts b/@types/memoizee/index.d.ts index ea3f6626b3..f549aebce6 100644 --- a/@types/memoizee/index.d.ts +++ b/@types/memoizee/index.d.ts @@ -6,10 +6,10 @@ declare namespace memoizee { max?: number | undefined; preFetch?: number | true | undefined; promise?: boolean | 'then' | 'done' | 'done:finally' | undefined; - dispose?(value: unknown): void; + dispose?: (value: unknown) => void; async?: boolean | undefined; primitive?: boolean | undefined; - normalizer?(args: Parameters): string; + normalizer?: (args: Parameters) => string; resolvers?: Array<(arg: unknown) => unknown> | undefined; } diff --git a/packages/code-studio/src/settings/ShortcutItem.tsx b/packages/code-studio/src/settings/ShortcutItem.tsx index a4e37449cc..4125a3392d 100644 --- a/packages/code-studio/src/settings/ShortcutItem.tsx +++ b/packages/code-studio/src/settings/ShortcutItem.tsx @@ -17,7 +17,7 @@ type ShortcutItemProps = { shortcut: Shortcut; displayText: string; categoryName: string; - onChange(shortcut: Shortcut): void; + onChange: (shortcut: Shortcut) => void; }; export default function ShortcutItem({ diff --git a/packages/code-studio/src/settings/ShortcutsSectionContent.tsx b/packages/code-studio/src/settings/ShortcutsSectionContent.tsx index 67f64fd92e..8d6efbf0a9 100644 --- a/packages/code-studio/src/settings/ShortcutsSectionContent.tsx +++ b/packages/code-studio/src/settings/ShortcutsSectionContent.tsx @@ -84,7 +84,7 @@ function ShortcutSectionContent({ type ShortcutCategoryProps = { name: string; shortcuts: Shortcut[]; - saveShortcutOverrides(shortcuts: Shortcut[]): void; + saveShortcutOverrides: (shortcuts: Shortcut[]) => void; }; function ShortcutCategory({ diff --git a/packages/console/src/command-history/CommandHistoryStorage.ts b/packages/console/src/command-history/CommandHistoryStorage.ts index d2948d001a..a956758e20 100644 --- a/packages/console/src/command-history/CommandHistoryStorage.ts +++ b/packages/console/src/command-history/CommandHistoryStorage.ts @@ -20,7 +20,7 @@ export interface CommandHistoryStorageItem extends StorageItem { export interface CommandHistoryTable extends StorageTable { - setSearch(search: string): void; + setSearch: (search: string) => void; } export interface CommandHistoryStorage { @@ -32,11 +32,11 @@ export interface CommandHistoryStorage { * @param scope The scope of this command history, to keep different command histories separate * @param timestamp The time this command history scope was started */ - getTable( + getTable: ( language: string, scope: string, timestamp: number - ): Promise; + ) => Promise; /** * Add a command to the command history @@ -45,22 +45,22 @@ export interface CommandHistoryStorage { * @param command The command to add to the history * @param data The data to save with the command */ - addItem( + addItem: ( language: string, scope: string, command: string, data: CommandHistoryStorageData - ): Promise; + ) => Promise; /** * Save a modified CommandHistoryStorageItem * @param language The language of the item to save * @param item The modified item to save */ - updateItem( + updateItem: ( language: string, item: CommandHistoryStorageItem - ): Promise; + ) => Promise; /** * Listen to an item with a specific id @@ -69,12 +69,12 @@ export interface CommandHistoryStorage { * @param id The id of the item to listen to * @param listener Called whenever there is an update on the item */ - listenItem( + listenItem: ( language: string, id: string, listener: StorageItemListener, onError?: StorageErrorListener - ): StorageListenerRemover; + ) => StorageListenerRemover; } export default CommandHistoryStorage; diff --git a/packages/console/src/csv/ZipStreamHelper.ts b/packages/console/src/csv/ZipStreamHelper.ts index 102182c69c..8ab842f2b6 100644 --- a/packages/console/src/csv/ZipStreamHelper.ts +++ b/packages/console/src/csv/ZipStreamHelper.ts @@ -7,8 +7,8 @@ import type { JSZipObject, OnUpdateCallback, JSZipStreamHelper } from 'jszip'; */ interface ZipStreamHelper extends JSZipStreamHelper { readable: boolean; - read(): void; - removeListener(): void; + read: () => void; + removeListener: () => void; } export default function makeZipStreamHelper( @@ -20,7 +20,7 @@ export default function makeZipStreamHelper( // The type could be anything except nodebuffer from https://stuk.github.io/jszip/documentation/api_zipobject/internal_stream.html // We only need it as a string though // JSZip types don't include this method for some reason - internalStream(type: 'string'): JSZipStreamHelper; + internalStream: (type: 'string') => JSZipStreamHelper; } ).internalStream('string') as ZipStreamHelper; diff --git a/packages/dashboard-core-plugins/src/panels/FilterSetManager.tsx b/packages/dashboard-core-plugins/src/panels/FilterSetManager.tsx index 83639c25cb..f2c8c211dd 100644 --- a/packages/dashboard-core-plugins/src/panels/FilterSetManager.tsx +++ b/packages/dashboard-core-plugins/src/panels/FilterSetManager.tsx @@ -54,10 +54,10 @@ interface FilterSetManagerProps { isValueShown: boolean; selectedId?: string; filterSets: FilterSet[]; - getFilterState(): FilterSetPanel[]; - onChange(args: ChangeHandlerArgs): void; - onApply(filterSet: FilterSet): void; - onUpdateSets(filterSets: FilterSet[], editId?: string): void; + getFilterState: () => FilterSetPanel[]; + onChange: (args: ChangeHandlerArgs) => void; + onApply: (filterSet: FilterSet) => void; + onUpdateSets: (filterSets: FilterSet[], editId?: string) => void; } interface FilterSetManagerState { diff --git a/packages/dashboard-core-plugins/src/panels/IrisGridPanel.test.tsx b/packages/dashboard-core-plugins/src/panels/IrisGridPanel.test.tsx index 6c18901525..ea4d107fe4 100644 --- a/packages/dashboard-core-plugins/src/panels/IrisGridPanel.test.tsx +++ b/packages/dashboard-core-plugins/src/panels/IrisGridPanel.test.tsx @@ -134,7 +134,7 @@ it('shows the loading spinner until grid is ready', async () => { await expectLoading(container); const params = ( MockIrisGrid.mock.calls[MockIrisGrid.mock.calls.length - 1] as unknown as { - onStateChange(param1: unknown, param2: unknown); + onStateChange: (param1: unknown, param2: unknown) => any; }[] )[0]; params.onStateChange({}, {}); diff --git a/packages/eslint-config/index.js b/packages/eslint-config/index.js index caed9f6ca2..75917b89f3 100644 --- a/packages/eslint-config/index.js +++ b/packages/eslint-config/index.js @@ -88,6 +88,7 @@ module.exports = { 'default-param-last': 'off', '@typescript-eslint/default-param-last': ['error'], '@typescript-eslint/explicit-module-boundary-types': 'error', + '@typescript-eslint/method-signature-style': 'error', }, }, { diff --git a/packages/file-explorer/src/FileExplorerToolbar.tsx b/packages/file-explorer/src/FileExplorerToolbar.tsx index fec3947a7b..b1d3ff9c4c 100644 --- a/packages/file-explorer/src/FileExplorerToolbar.tsx +++ b/packages/file-explorer/src/FileExplorerToolbar.tsx @@ -4,9 +4,9 @@ import { vsNewFile, vsNewFolder } from '@deephaven/icons'; import './FileExplorerToolbar.scss'; type FileExplorerToolbarProps = { - createFile(): void; - createFolder(): void; - onSearchChange?(text: string): void; + createFile: () => void; + createFolder: () => void; + onSearchChange?: (text: string) => void; defaultSearchText?: string; }; diff --git a/packages/file-explorer/src/FileListItem.tsx b/packages/file-explorer/src/FileListItem.tsx index 97d8394846..71714049fc 100644 --- a/packages/file-explorer/src/FileListItem.tsx +++ b/packages/file-explorer/src/FileListItem.tsx @@ -34,10 +34,10 @@ export type FileListRenderItemProps = RenderItemProps & { isDragInProgress: boolean; isDropTargetValid: boolean; - onDragStart(index: number, e: React.DragEvent): void; - onDragOver(index: number, e: React.DragEvent): void; - onDragEnd(index: number, e: React.DragEvent): void; - onDrop(index: number, e: React.DragEvent): void; + onDragStart: (index: number, e: React.DragEvent) => void; + onDragOver: (index: number, e: React.DragEvent) => void; + onDragEnd: (index: number, e: React.DragEvent) => void; + onDrop: (index: number, e: React.DragEvent) => void; }; export function FileListItem(props: FileListRenderItemProps): JSX.Element { diff --git a/packages/file-explorer/src/FileStorage.ts b/packages/file-explorer/src/FileStorage.ts index dda81c6d85..88d38ddbb3 100644 --- a/packages/file-explorer/src/FileStorage.ts +++ b/packages/file-explorer/src/FileStorage.ts @@ -36,18 +36,18 @@ export interface File extends FileMetadata { } export interface FileStorageTable extends StorageTable { - setSearch(search: string): void; + setSearch: (search: string) => void; /** * @param path The path to expand * @param expanded What expanded state to set */ - setExpanded(path: string, expanded: boolean): void; + setExpanded: (path: string, expanded: boolean) => void; /** * Collapses all directories */ - collapseAll(): void; + collapseAll: () => void; } /** @@ -57,39 +57,39 @@ export interface FileStorage { /** * Retrieve a table to view the file list */ - getTable(): Promise; + getTable: () => Promise; /** * Save a file * @param file The file to save */ - saveFile(file: File): Promise; + saveFile: (file: File) => Promise; /** * Load the contents of a file * @param name The file to load, including the full path */ - loadFile(name: string): Promise; + loadFile: (name: string) => Promise; /** * Delete a file * @param name The full name of the file to delete */ - deleteFile(name: string): Promise; + deleteFile: (name: string) => Promise; /** * Move a file to a new location * @param name Source file name * @param newName The new file name, including path */ - moveFile(name: string, newName: string): Promise; + moveFile: (name: string, newName: string) => Promise; /** * Copy a file to a new location * @param name The name of the file to copy * @param newName The new file name, including path */ - copyFile(name: string, newName: string): Promise; + copyFile: (name: string, newName: string) => Promise; /** * Get the info for the file at the specified path. @@ -97,13 +97,13 @@ export interface FileStorage { * @param name The file name to check, including path * @returns The FileStorageItem for the path specified, or reject with a FileNotFoundError if it does not exist. */ - info(name: string): Promise; + info: (name: string) => Promise; /** * Create the directory at the given path * @param name The full directory path */ - createDirectory(name: string): Promise; + createDirectory: (name: string) => Promise; } export default FileStorage; diff --git a/packages/grid/src/ColumnHeaderGroup.ts b/packages/grid/src/ColumnHeaderGroup.ts index 5dbba117a1..42e94e85d7 100644 --- a/packages/grid/src/ColumnHeaderGroup.ts +++ b/packages/grid/src/ColumnHeaderGroup.ts @@ -5,5 +5,5 @@ export interface IColumnHeaderGroup { name: string; depth: number; color?: string; - getVisibleRange(movedColumns: readonly MoveOperation[]): BoundedAxisRange; + getVisibleRange: (movedColumns: readonly MoveOperation[]) => BoundedAxisRange; } diff --git a/packages/grid/src/DataBarGridModel.ts b/packages/grid/src/DataBarGridModel.ts index b185ad899b..1e96c909eb 100644 --- a/packages/grid/src/DataBarGridModel.ts +++ b/packages/grid/src/DataBarGridModel.ts @@ -50,9 +50,9 @@ export function isDataBarGridModel( } export interface DataBarGridModel extends GridModel { - dataBarOptionsForCell( + dataBarOptionsForCell: ( column: ModelIndex, row: ModelIndex, theme: GridThemeType - ): DataBarOptions; + ) => DataBarOptions; } diff --git a/packages/grid/src/EditableGridModel.ts b/packages/grid/src/EditableGridModel.ts index c78c2c3db2..8840479fdc 100644 --- a/packages/grid/src/EditableGridModel.ts +++ b/packages/grid/src/EditableGridModel.ts @@ -49,7 +49,7 @@ export interface EditableGridModel extends GridModel { * @param range The range to check if it is editable * @returns True if the range is editable */ - isEditableRange(range: GridRange): boolean; + isEditableRange: (range: GridRange) => boolean; /** * Get the edit text for a cell as a string @@ -57,7 +57,7 @@ export interface EditableGridModel extends GridModel { * @param row Row to get * @returns The value to use for editing */ - editValueForCell(column: ModelIndex, row: ModelIndex): string; + editValueForCell: (column: ModelIndex, row: ModelIndex) => string; /** * Set value in an editable table @@ -66,11 +66,11 @@ export interface EditableGridModel extends GridModel { * @param value The value to set * @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error */ - setValueForCell( + setValueForCell: ( column: ModelIndex, row: ModelIndex, value: string - ): Promise; + ) => Promise; /** * Set value in an editable table @@ -78,14 +78,17 @@ export interface EditableGridModel extends GridModel { * @param value The value to set * @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error */ - setValueForRanges(ranges: readonly GridRange[], value: string): Promise; + setValueForRanges: ( + ranges: readonly GridRange[], + value: string + ) => Promise; /** * Apply edits to the model * @param edits Edits to apply to the model * @returns A promise that resolves successfully when the operation is complete or rejects if there's an error */ - setValues(edits: readonly EditOperation[]): Promise; + setValues: (edits: readonly EditOperation[]) => Promise; /** * Check if a text value is a valid edit for a cell @@ -94,7 +97,11 @@ export interface EditableGridModel extends GridModel { * @param value Value to check if it's a valid value or not * @returns True if it's a valid value, false otherwise */ - isValidForCell(column: ModelIndex, row: ModelIndex, value: string): boolean; + isValidForCell: ( + column: ModelIndex, + row: ModelIndex, + value: string + ) => boolean; } export default EditableGridModel; diff --git a/packages/grid/src/ExpandableGridModel.ts b/packages/grid/src/ExpandableGridModel.ts index 12bb124957..4e8cee6784 100644 --- a/packages/grid/src/ExpandableGridModel.ts +++ b/packages/grid/src/ExpandableGridModel.ts @@ -21,13 +21,13 @@ export interface ExpandableGridModel extends GridModel { * @param row Row to check * @returns True if the row is expandable */ - isRowExpandable(row: ModelIndex): boolean; + isRowExpandable: (row: ModelIndex) => boolean; /** * @param row Row to check * @returns True if the row is currently expanded */ - isRowExpanded(row: ModelIndex): boolean; + isRowExpanded: (row: ModelIndex) => boolean; /** * Change the expanded status of an expandable row @@ -35,28 +35,28 @@ export interface ExpandableGridModel extends GridModel { * @param isExpanded True to expand the row, false to collapse * @param expandDescendants True to expand nested rows, false otherwise */ - setRowExpanded( + setRowExpanded: ( row: ModelIndex, isExpanded: boolean, expandDescendants?: boolean - ): void; + ) => void; /** * Expand all rows */ - expandAll(): void; + expandAll: () => void; /** * Collapse all rows */ - collapseAll(): void; + collapseAll: () => void; /** * Get the depth of a row (ie. How indented the row should be) * @param row Row to check * @returns Depth of the row */ - depthForRow(row: ModelIndex): number; + depthForRow: (row: ModelIndex) => number; } export default ExpandableGridModel; diff --git a/packages/grid/src/TokenBoxCellRenderer.ts b/packages/grid/src/TokenBoxCellRenderer.ts index 834205e82e..8bbb5bde16 100644 --- a/packages/grid/src/TokenBoxCellRenderer.ts +++ b/packages/grid/src/TokenBoxCellRenderer.ts @@ -13,11 +13,11 @@ export function isTokenBoxCellRenderer( } interface TokenBoxCellRenderer extends CellRenderer { - getTokenBoxesForVisibleCell( + getTokenBoxesForVisibleCell: ( column: VisibleIndex, row: VisibleIndex, state: GridRenderState - ): TokenBox[]; + ) => TokenBox[]; } export default TokenBoxCellRenderer; diff --git a/packages/iris-grid/src/AdvancedFilterCreatorFilterItem.tsx b/packages/iris-grid/src/AdvancedFilterCreatorFilterItem.tsx index 4fb5c33bff..0489bbf0fd 100644 --- a/packages/iris-grid/src/AdvancedFilterCreatorFilterItem.tsx +++ b/packages/iris-grid/src/AdvancedFilterCreatorFilterItem.tsx @@ -25,8 +25,8 @@ const log = Log.module('AdvancedFilterCreatorFilterItem'); export interface AdvancedFilterCreatorFilterItemProps { column: Column; filterTypes: FilterTypeValue[]; - onChange(type: FilterTypeValue, value: string): void; - onDelete(): void; + onChange: (type: FilterTypeValue, value: string) => void; + onDelete: () => void; selectedType?: FilterTypeValue; value?: string; formatter: Formatter; diff --git a/packages/iris-grid/src/IrisGrid.test.tsx b/packages/iris-grid/src/IrisGrid.test.tsx index ea9a58ac6f..352d9afa86 100644 --- a/packages/iris-grid/src/IrisGrid.test.tsx +++ b/packages/iris-grid/src/IrisGrid.test.tsx @@ -3,6 +3,7 @@ import TestRenderer from 'react-test-renderer'; import dh from '@deephaven/jsapi-shim'; import { DateUtils, Settings } from '@deephaven/jsapi-utils'; import { TestUtils } from '@deephaven/utils'; +import { TypeValue } from '@deephaven/filters'; import { IrisGrid } from './IrisGrid'; import IrisGridTestUtils from './IrisGridTestUtils'; @@ -181,7 +182,7 @@ it('handles undefined operator, should default to eq', () => { columnType: IrisGridTestUtils.DEFAULT_TYPE, filterList: [ { - operator: undefined, + operator: undefined as unknown as TypeValue, text: 'any', value: 'any', startColumnIndex: 0, diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.tsx index 9ce9f98eae..c2ab82acff 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingGroup.tsx @@ -15,10 +15,10 @@ import './VisibilityOrderingGroup.scss'; interface VisibilityOrderingGroupProps { group: ColumnHeaderGroup; - onDelete(group: ColumnHeaderGroup): void; - onColorChange(group: ColumnHeaderGroup, color: string | undefined): void; - onNameChange(group: ColumnHeaderGroup, name: string): void; - validateName(name: string): string; + onDelete: (group: ColumnHeaderGroup) => void; + onColorChange: (group: ColumnHeaderGroup, color: string | undefined) => void; + onNameChange: (group: ColumnHeaderGroup, name: string) => void; + validateName: (name: string) => string; } export default function VisibilityOrderingGroup( diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx index 71bbb6f26c..026162380f 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx @@ -13,12 +13,15 @@ type VisibilityOrderingItemProps = { clone: boolean; childCount: number; item: FlattenedIrisGridTreeItem; - onVisibilityChange(modelIndexes: number[], isVisible: boolean): void; - onClick(name: string, event: React.MouseEvent): void; - onGroupDelete(group: ColumnHeaderGroup): void; - onGroupColorChange(group: ColumnHeaderGroup, color: string | undefined): void; - onGroupNameChange(group: ColumnHeaderGroup, name: string): void; - validateGroupName(name: string): string; + onVisibilityChange: (modelIndexes: number[], isVisible: boolean) => void; + onClick: (name: string, event: React.MouseEvent) => void; + onGroupDelete: (group: ColumnHeaderGroup) => void; + onGroupColorChange: ( + group: ColumnHeaderGroup, + color: string | undefined + ) => void; + onGroupNameChange: (group: ColumnHeaderGroup, name: string) => void; + validateGroupName: (name: string) => string; handleProps: Record; }; diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx index 35ea8ca12f..dda9a5368a 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx @@ -43,14 +43,14 @@ interface Props { items: TreeItem[]; indentationWidth?: number; indicator?: boolean; - onDragStart?(id: string): void; - onDragEnd?(from: FlattenedItem, to: FlattenedItem): void; - renderItem(props: { + onDragStart?: (id: string) => void; + onDragEnd?: (from: FlattenedItem, to: FlattenedItem) => void; + renderItem: (props: { clone: boolean; childCount?: number; value: string; item: FlattenedItem; - }): JSX.Element; + }) => JSX.Element; } export default function SortableTree({ diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx index a2ef0c537a..4bcfd73f96 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx @@ -80,12 +80,12 @@ interface Props { items: FlattenedItem[]; indentationWidth?: number; indicator?: boolean; - renderItem(props: { + renderItem: (props: { clone: boolean; childCount?: number; value: string; item: FlattenedItem; - }): JSX.Element; + }) => JSX.Element; activeId: string | null; overId: string | null; offsetLeft: number; diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx index 18aabde9dd..9025631033 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx @@ -15,14 +15,14 @@ export interface Props { item: FlattenedItem; dragRef?: React.Ref | null; wrapperRef?: React.Ref | null; - renderItem(props: { + renderItem: (props: { ref: React.Ref | null; clone: boolean; childCount?: number; value: string; item: FlattenedItem; handleProps: unknown; - }): JSX.Element; + }) => JSX.Element; } export type TreeItemRenderFn = (props: { diff --git a/packages/jsapi-components/src/TableInput.tsx b/packages/jsapi-components/src/TableInput.tsx index 53552c5a91..553556ee25 100644 --- a/packages/jsapi-components/src/TableInput.tsx +++ b/packages/jsapi-components/src/TableInput.tsx @@ -37,7 +37,7 @@ interface TableInputProps { defaultValue: Value[]; isInvalid?: boolean; table: Promise; - onChange(items: Value[]): void; + onChange: (items: Value[]) => void; onBlur?: () => void; } diff --git a/packages/jsapi-types/src/dh.types.ts b/packages/jsapi-types/src/dh.types.ts index d8cd8bf65a..1dd757a0fd 100644 --- a/packages/jsapi-types/src/dh.types.ts +++ b/packages/jsapi-types/src/dh.types.ts @@ -153,56 +153,59 @@ export interface IdeSessionStatic { } export interface WorkerConnection { - subscribeToFieldUpdates( + subscribeToFieldUpdates: ( param: (changes: VariableChanges) => void - ): () => void; + ) => () => void; } export interface IdeSession extends Evented { - subscribeToFieldUpdates( + subscribeToFieldUpdates: ( param: (changes: VariableChanges) => void - ): () => void; - getTable(name: string): Promise
; - getFigure(name: string): Promise
; - getTreeTable(name: string): Promise; - getObject( + ) => () => void; + getTable: (name: string) => Promise
; + getFigure: (name: string) => Promise
; + getTreeTable: (name: string) => Promise; + getObject: (( definition: VariableDefinition - ): Promise
; - getObject( - definition: VariableDefinition - ): Promise
; - getObject( - definition: VariableDefinition - ): Promise; - getObject( - definition: VariableDefinition - ): Promise; - getObject(definition: VariableDefinition): Promise; - onLogMessage(logHandler: (logItem: LogItem) => void): () => void; - runCode(code: string): Promise; - bindTableToVariable(table: Table, variableName: string): Promise; - mergeTables(tables: Table[]): Promise
; - newTable( + ) => Promise
) & + (( + definition: VariableDefinition + ) => Promise
) & + (( + definition: VariableDefinition + ) => Promise) & + (( + definition: VariableDefinition + ) => Promise) & + ((definition: VariableDefinition) => Promise); + onLogMessage: (logHandler: (logItem: LogItem) => void) => () => void; + runCode: (code: string) => Promise; + bindTableToVariable: (table: Table, variableName: string) => Promise; + mergeTables: (tables: Table[]) => Promise
; + newTable: ( columnNames: string[], columnTypes: string[], data: string[][], userTimeZone: string - ): Promise
; - getCompletionItems(params: unknown): Promise; - getSignatureHelp?(params: unknown): Promise; - getHover?(params: unknown): Promise; - closeDocument(params: unknown): void; - openDocument(params: unknown): void; - changeDocument(params: unknown): void; - close(): void; + ) => Promise
; + getCompletionItems: (params: unknown) => Promise; + getSignatureHelp?: (params: unknown) => Promise; + getHover?: (params: unknown) => Promise; + closeDocument: (params: unknown) => void; + openDocument: (params: unknown) => void; + changeDocument: (params: unknown) => void; + close: () => void; } export interface Evented { - addEventListener(eventType: string, listener: EventListener): RemoverFn; - nextEvent(eventType: string, timeoutInMillis?: number): Promise; + addEventListener: (eventType: string, listener: EventListener) => RemoverFn; + nextEvent: ( + eventType: string, + timeoutInMillis?: number + ) => Promise; - hasListeners(eventType: string): boolean; - removeEventListener(eventType: string, listener: EventListener): boolean; + hasListeners: (eventType: string) => boolean; + removeEventListener: (eventType: string, listener: EventListener) => boolean; } export interface Plot { @@ -310,7 +313,7 @@ export interface Figure extends Evented { readonly EVENT_SERIES_ADDED: string; /** Given a client-created figure descriptor, generate a figure that can be subscribed to */ - create(figure: Partial): Promise
; + create: (figure: Partial) => Promise
; readonly title: string; readonly titleFont: string; @@ -326,14 +329,14 @@ export interface Figure extends Evented { * Subscribes to all series in this figure. * @param forceDisableDownsample optional, can be specified to force downsampling to be disabled */ - subscribe(forceDisableDownsample?: DownsampleOptions): void; + subscribe: (forceDisableDownsample?: DownsampleOptions) => void; /** * Unsubscribes to all series in this figure. */ - unsubscribe(): void; + unsubscribe: () => void; - close(): void; + close: () => void; } export type WidgetExportedObject = { @@ -349,9 +352,9 @@ export interface Widget { type: string, listener: (event: unknown) => void ) => () => void; - getDataAsBase64(): string; - getDataAsString(): string; - getDataAsU8(): Uint8Array; + getDataAsBase64: () => string; + getDataAsString: () => string; + getDataAsU8: () => Uint8Array; sendMessage: (message: string, references?: never[]) => void; exportedObjects: WidgetExportedObject[]; } @@ -375,11 +378,11 @@ export interface FigureDataUpdatedEvent { * @param sourceType * @param mapFn */ - getArray( + getArray: ( series: Series, sourceType: SourceType, mapFn?: MapFn - ): O[]; + ) => O[]; } export interface MapFn { @@ -493,8 +496,8 @@ export interface Series { readonly multiSeries: MultiSeries; readonly oneClick: OneClick; - subscribe(downsampleOptions?: DownsampleOptions): void; - unsubscribe(): void; + subscribe: (downsampleOptions?: DownsampleOptions) => void; + unsubscribe: () => void; } export interface MultiSeries { @@ -555,7 +558,7 @@ export interface Axis { * be returned, to ensure that lines drawn off the screen. * @param max the optional max value visible on this axis. If min is specified, max is also expected. */ - range(pixelCount?: number, min?: any, max?: any): void; + range: (pixelCount?: number, min?: any, max?: any) => void; } export interface SeriesDataSource { @@ -568,8 +571,8 @@ export interface OneClick { readonly columns: { name: string; type: string }[]; readonly requireAllFiltersToDisplay: boolean; - setValueForColumn(columnName: string, value: any): void; - getValueForColumn(columnName: string): any; + setValueForColumn: (columnName: string, value: any) => void; + getValueForColumn: (columnName: string) => any; } export interface Column { @@ -581,11 +584,11 @@ export interface Column { readonly isPartitionColumn: boolean; readonly isSortable?: boolean; - filter(): FilterValue; - sort(): Sort; + filter: () => FilterValue; + sort: () => Sort; - formatColor(expression: string): CustomColumn; - formatRowColor(expression: string): CustomColumn; + formatColor: (expression: string) => CustomColumn; + formatRowColor: (expression: string) => CustomColumn; } export interface CustomColumn { @@ -595,55 +598,55 @@ export interface CustomColumn { } export interface FilterValueStatic { - ofString(input: unknown): FilterValue; - ofNumber(input: unknown): FilterValue; - ofBoolean(input: unknown): FilterValue; + ofString: (input: unknown) => FilterValue; + ofNumber: (input: unknown) => FilterValue; + ofBoolean: (input: unknown) => FilterValue; } export interface FilterValue { - eq(value: FilterValue): FilterCondition; - eqIgnoreCase(value: FilterValue): FilterCondition; - notEq(value: FilterValue): FilterCondition; - notEqIgnoreCase(value: FilterValue): FilterCondition; - greaterThan(value: FilterValue): FilterCondition; - lessThan(value: FilterValue): FilterCondition; - greaterThanOrEqualTo(value: FilterValue): FilterCondition; - lessThanOrEqualTo(value: FilterValue): FilterCondition; - in(values: FilterValue[]): FilterCondition; - inIgnoreCase(values: FilterValue[]): FilterCondition; - notIn(values: FilterValue[]): FilterCondition; - notInIgnoreCase(values: FilterValue[]): FilterCondition; - contains(value: FilterValue): FilterCondition; - containsIgnoreCase(value: FilterValue): FilterCondition; - isFalse(): FilterCondition; - isTrue(): FilterCondition; - isNull(): FilterCondition; - invoke(method: string, ...args: FilterValue[]): FilterCondition; - matches(value: FilterValue): FilterCondition; - matchesIgnoreCase(value: FilterValue): FilterCondition; + eq: (value: FilterValue) => FilterCondition; + eqIgnoreCase: (value: FilterValue) => FilterCondition; + notEq: (value: FilterValue) => FilterCondition; + notEqIgnoreCase: (value: FilterValue) => FilterCondition; + greaterThan: (value: FilterValue) => FilterCondition; + lessThan: (value: FilterValue) => FilterCondition; + greaterThanOrEqualTo: (value: FilterValue) => FilterCondition; + lessThanOrEqualTo: (value: FilterValue) => FilterCondition; + in: (values: FilterValue[]) => FilterCondition; + inIgnoreCase: (values: FilterValue[]) => FilterCondition; + notIn: (values: FilterValue[]) => FilterCondition; + notInIgnoreCase: (values: FilterValue[]) => FilterCondition; + contains: (value: FilterValue) => FilterCondition; + containsIgnoreCase: (value: FilterValue) => FilterCondition; + isFalse: () => FilterCondition; + isTrue: () => FilterCondition; + isNull: () => FilterCondition; + invoke: (method: string, ...args: FilterValue[]) => FilterCondition; + matches: (value: FilterValue) => FilterCondition; + matchesIgnoreCase: (value: FilterValue) => FilterCondition; } export interface FilterConditionStatic { - invoke(method: string, ...args: FilterValue[]): FilterCondition; - search(value: FilterValue, columns?: FilterValue[]): FilterCondition; + invoke: (method: string, ...args: FilterValue[]) => FilterCondition; + search: (value: FilterValue, columns?: FilterValue[]) => FilterCondition; } export interface FilterCondition { - not(): FilterCondition; - and(first: FilterCondition, ...rest: FilterCondition[]): FilterCondition; - or(first: FilterCondition, ...rest: FilterCondition[]): FilterCondition; + not: () => FilterCondition; + and: (first: FilterCondition, ...rest: FilterCondition[]) => FilterCondition; + or: (first: FilterCondition, ...rest: FilterCondition[]) => FilterCondition; - toString(): string; + toString: () => string; } export interface Sort { - reverse(): Sort; + reverse: () => Sort; readonly column: Column; readonly direction: 'ASC' | 'DESC' | 'REVERSE' | null; readonly isAbs: boolean; - asc(): Sort; - desc(): Sort; - abs(): Sort; + asc: () => Sort; + desc: () => Sort; + abs: () => Sort; } export interface InputTable { @@ -651,18 +654,18 @@ export interface InputTable { keyColumns: Column[]; values: string[]; valueColumns: Column[]; - addRow( + addRow: ( row: Record, userTimeZone?: string - ): Promise; - addRows( + ) => Promise; + addRows: ( rows: Record[], userTimeZone?: string - ): Promise; - addTable(table: Table): Promise; - addTables(tables: Table[]): Promise; - deleteTable(table: Table): Promise; - deleteTables(tables: Table[]): Promise; + ) => Promise; + addTable: (table: Table) => Promise; + addTables: (tables: Table[]) => Promise; + deleteTable: (table: Table) => Promise; + deleteTables: (tables: Table[]) => Promise; table: Table; } export interface ColumnGroup { @@ -700,7 +703,7 @@ export interface TableStatic { readonly EVENT_RECONNECT: string; readonly EVENT_RECONNECTFAILED: string; readonly SIZE_UNCOALESCED: number; - reverse(): Sort; + reverse: () => Sort; } export interface ClientStatic { @@ -723,41 +726,41 @@ export interface Table extends TableTemplate
, TableStatic { readonly isClosed: boolean; readonly pluginName: string; - applyCustomColumns(columns: (CustomColumn | string)[]): string[]; + applyCustomColumns: (columns: (CustomColumn | string)[]) => string[]; - getViewportData(): Promise; + getViewportData: () => Promise; - subscribe(columns: Column[]): TableSubscription; + subscribe: (columns: Column[]) => TableSubscription; - selectDistinct(columns: Column[]): Promise
; - copy(): Promise
; + selectDistinct: (columns: Column[]) => Promise
; + copy: () => Promise
; - rollup(config: RollupConfig): Promise; - treeTable(config: TreeTableConfig): Promise; + rollup: (config: RollupConfig) => Promise; + treeTable: (config: TreeTableConfig) => Promise; - inputTable(): Promise; + inputTable: () => Promise; - freeze(): Promise
; + freeze: () => Promise
; - snapshot( + snapshot: ( rightHandSide: Table, doInitialSnapshot?: boolean, stampColumns?: string[] - ): Promise
; + ) => Promise
; - getColumnStatistics(column: Column): Promise; + getColumnStatistics: (column: Column) => Promise; - join( + join: ( joinType: string, rightTable: Table, columnsToMatch: string[], columnsToAdd?: string[] - ): Promise
; - byExternal(keys: string[], dropKeys?: boolean): Promise; + ) => Promise
; + byExternal: (keys: string[], dropKeys?: boolean) => Promise; - fireViewportUpdate(): void; + fireViewportUpdate: () => void; - seekRow( + seekRow: ( startRow: number, column: Column, valueType: ValueTypeUnion, @@ -765,14 +768,14 @@ export interface Table extends TableTemplate
, TableStatic { insensitive?: boolean, contains?: boolean, isBackwards?: boolean - ): Promise; + ) => Promise; } export interface TableViewportSubscription extends Evented { - setViewport(firstRow: number, lastRow: number, columns?: Column[]): void; - getViewportData(): Promise; - snapshot(rows: RangeSet, columns: readonly Column[]): Promise; - close(): void; + setViewport: (firstRow: number, lastRow: number, columns?: Column[]) => void; + getViewportData: () => Promise; + snapshot: (rows: RangeSet, columns: readonly Column[]) => Promise; + close: () => void; } export interface ViewportData { @@ -785,32 +788,32 @@ export interface TableSubscription extends Evented { readonly EVENT_UPDATED: string; readonly columns: Column[]; - close(): void; + close: () => void; } export interface RangeSet { - ofRange(first: number, last: number): RangeSet; - ofItems(rows: number[]): RangeSet; - ofRanges(ranges: RangeSet[]): RangeSet; + ofRange: (first: number, last: number) => RangeSet; + ofItems: (rows: number[]) => RangeSet; + ofRanges: (ranges: RangeSet[]) => RangeSet; readonly size: number; - iterator(): JsIterator; + iterator: () => JsIterator; } export interface JsIterator { - hasNext(): boolean; - next(): IteratorResult; + hasNext: () => boolean; + next: () => IteratorResult; } export interface LongWrapper { - asNumber(): number; - valueOf(): string; - toString(): string; - ofString(str: string): LongWrapper; + asNumber: () => number; + valueOf: () => string; + toString: () => string; + ofString: (str: string) => LongWrapper; } export interface DateWrapper extends LongWrapper { - ofJsDate(date: Date): DateWrapper; - asDate(): Date; + ofJsDate: (date: Date) => DateWrapper; + asDate: () => Date; } export interface TimeZone { @@ -823,36 +826,35 @@ export interface TimeZone { } export interface i18nTimeZone { - getTimeZone(tzCode: string): TimeZone; + getTimeZone: (tzCode: string) => TimeZone; } export interface DateTimeFormat { - format( + format: ( pattern: string, date: DateWrapper | Date | number, timeZone?: TimeZone - ): string; - parse(pattern: string, text: string, timeZone?: TimeZone): DateWrapper; - parseAsDate(pattern: string, text: string): Date; + ) => string; + parse: (pattern: string, text: string, timeZone?: TimeZone) => DateWrapper; + parseAsDate: (pattern: string, text: string) => Date; } export interface NumberFormat { - format(pattern: string, number: number): string; - parse(pattern: string, text: string): number; + format: (pattern: string, number: number) => string; + parse: (pattern: string, text: string) => number; } export interface TableData { readonly columns: Column[]; readonly rows: Row[]; - get(index: number): Row; - get(index: LongWrapper): Row; + get: ((index: number) => Row) & ((index: LongWrapper) => Row); - getData(index: number, column: Column): any; - getData(index: LongWrapper, column: Column): any; + getData: ((index: number, column: Column) => any) & + ((index: LongWrapper, column: Column) => any); - getFormat(index: number, column: Column): Format; - getFormat(index: LongWrapper, column: Column): Format; + getFormat: ((index: number, column: Column) => Format) & + ((index: LongWrapper, column: Column) => Format); } export interface UpdateEventData extends TableData { @@ -865,9 +867,9 @@ export interface UpdateEventData extends TableData { export interface Row { readonly index: LongWrapper; - get(column: Column): any; + get: (column: Column) => any; - getFormat(column: Column): Format; + getFormat: (column: Column) => Format; } export interface Format { @@ -895,7 +897,7 @@ export interface ColumnStatistics { readonly statisticsMap: Map; readonly uniqueValues: Map; - getType(name: string): string; + getType: (name: string) => string; } export interface TreeTableStatic { @@ -912,54 +914,47 @@ export interface TableTemplate extends Evented { readonly filter: FilterCondition[]; readonly totalsTableConfig: TotalsTableConfig; - findColumn(name: string): Column; - findColumns(names: string[]): Column[]; + findColumn: (name: string) => Column; + findColumns: (names: string[]) => Column[]; - applySort(sorts: Sort[]): Sort[]; - applyFilter(filters: FilterCondition[]): FilterCondition[]; - selectDistinct(columns: Column[]): Promise
; + applySort: (sorts: Sort[]) => Sort[]; + applyFilter: (filters: FilterCondition[]) => FilterCondition[]; + selectDistinct: (columns: Column[]) => Promise
; - getTotalsTable(config?: TotalsTableConfig): Promise; - getGrandTotalsTable(config?: TotalsTableConfig): Promise; + getTotalsTable: (config?: TotalsTableConfig) => Promise; + getGrandTotalsTable: (config?: TotalsTableConfig) => Promise; - setViewport( + setViewport: ( firstRow: number, lastRow: number, columns?: Column[], updateIntervalMs?: number - ): TableViewportSubscription; + ) => TableViewportSubscription; - copy(): Promise; - close(): void; + copy: () => Promise; + close: () => void; } export interface TreeTable extends TableTemplate, TreeTableStatic { readonly isIncludeConstituents: boolean; readonly groupedColumns: Column[]; - expand(row: number): void; - expand(row: TreeRow): void; - collapse(row: number): void; - collapse(row: TreeRow): void; - setExpanded( + expand: ((row: number) => void) & ((row: TreeRow) => void); + collapse: ((row: number) => void) & ((row: TreeRow) => void); + setExpanded: (( row: number, isExpanded: boolean, expandDescendants?: boolean - ): void; - setExpanded( - row: TreeRow, - isExpanded: boolean, - expandDescendants?: boolean - ): void; - expandAll?(): void; - collapseAll?(): void; - isExpanded(row: number): boolean; - isExpanded(row: TreeRow): boolean; + ) => void) & + ((row: TreeRow, isExpanded: boolean, expandDescendants?: boolean) => void); + expandAll?: () => void; + collapseAll?: () => void; + isExpanded: ((row: number) => boolean) & ((row: TreeRow) => boolean); - getViewportData(): Promise; + getViewportData: () => Promise; - saveExpandedState(): string; - restoreExpandedState(nodesToRestore: string): void; + saveExpandedState: () => string; + restoreExpandedState: (nodesToRestore: string) => void; } export interface TreeTableData extends TableData { readonly rows: TreeRow[]; @@ -998,26 +993,26 @@ export interface TotalsTable extends Evented { readonly totalsTableConfig: TotalsTableConfig; - applySort(sorts: Sort[]): Sort[]; - applyFilter(filters: FilterCondition[]): FilterCondition[]; - applyCustomColumns(columns: string[]): string[]; + applySort: (sorts: Sort[]) => Sort[]; + applyFilter: (filters: FilterCondition[]) => FilterCondition[]; + applyCustomColumns: (columns: string[]) => string[]; - setViewport( + setViewport: ( firstRow: number, lastRow: number, columns?: Column[], updateIntervalMs?: number - ): void; - getViewportData(): Promise; + ) => void; + getViewportData: () => Promise; - close(): void; + close: () => void; } export interface TableMap extends Evented { readonly size: number; - close(): void; - getKeys(): Promise>; - getTable(key: object): Promise
; + close: () => void; + getKeys: () => Promise>; + getTable: (key: object) => Promise
; } export interface WorkerHeapInfo { @@ -1027,9 +1022,9 @@ export interface WorkerHeapInfo { } export interface QueryConnectable extends Evented { - getWorkerHeapInfo(): Promise; - getConsoleTypes(): Promise; - startSession(type: string): Promise; + getWorkerHeapInfo: () => Promise; + getConsoleTypes: () => Promise; + startSession: (type: string) => Promise; } export interface IdeConnectionOptions { @@ -1050,25 +1045,25 @@ export interface IdeConnectionConstructor { export interface IdeConnection extends QueryConnectable, IdeConnectionConstructor { - close(): void; - running(): Promise; - disconnected(): void; - getObject( + close: () => void; + running: () => Promise; + disconnected: () => void; + getObject: (( definition: VariableDefinition - ): Promise
; - getObject( - definition: VariableDefinition - ): Promise
; - getObject( - definition: VariableDefinition - ): Promise; - getObject( - definition: VariableDefinition - ): Promise; - getObject(definition: VariableDefinition): Promise; - subscribeToFieldUpdates( + ) => Promise
) & + (( + definition: VariableDefinition + ) => Promise
) & + (( + definition: VariableDefinition + ) => Promise) & + (( + definition: VariableDefinition + ) => Promise) & + ((definition: VariableDefinition) => Promise); + subscribeToFieldUpdates: ( param: (changes: VariableChanges) => void - ): () => void; + ) => () => void; } export interface ItemDetails { @@ -1081,14 +1076,14 @@ export interface ItemDetails { } export interface FileContentsStatic { - blob(blob: Blob): FileContents; - text(...text: string[]): FileContents; - arrayBuffers(...buffers: ArrayBuffer[]): FileContents; + blob: (blob: Blob) => FileContents; + text: (...text: string[]) => FileContents; + arrayBuffers: (...buffers: ArrayBuffer[]) => FileContents; } export interface FileContents { - text(): Promise; - arrayBuffer(): Promise; + text: () => Promise; + arrayBuffer: () => Promise; etag?: string; } @@ -1098,16 +1093,16 @@ export interface LoginOptions { } export interface StorageService { - listItems(path: string, glob?: string): Promise; - loadFile(path: string, etag?: string): Promise; - deleteItem(path: string): Promise; - saveFile( + listItems: (path: string, glob?: string) => Promise; + loadFile: (path: string, etag?: string) => Promise; + deleteItem: (path: string) => Promise; + saveFile: ( path: string, contents: FileContents, allowOverwrite?: boolean - ): Promise; - moveItem(path: string, newPath: string, newFile?: boolean): Promise; - createDirectory(path: string): Promise; + ) => Promise; + moveItem: (path: string, newPath: string, newFile?: boolean) => Promise; + createDirectory: (path: string) => Promise; } export interface ConnectOptions { @@ -1125,12 +1120,12 @@ export interface CoreClientContructor extends Evented { } export interface CoreClient extends CoreClientContructor { - login(options: LoginOptions): Promise; - getAsIdeConnection(): Promise; - getStorageService(): StorageService; - getServerConfigValues(): Promise<[string, string][]>; - getAuthConfigValues(): Promise<[string, string][]>; - disconnect(): void; + login: (options: LoginOptions) => Promise; + getAsIdeConnection: () => Promise; + getStorageService: () => StorageService; + getServerConfigValues: () => Promise<[string, string][]>; + getAuthConfigValues: () => Promise<[string, string][]>; + disconnect: () => void; } /** diff --git a/packages/plugin/src/PluginTypes.ts b/packages/plugin/src/PluginTypes.ts index 86b513dff7..49b47db17c 100644 --- a/packages/plugin/src/PluginTypes.ts +++ b/packages/plugin/src/PluginTypes.ts @@ -125,7 +125,7 @@ export interface AuthPlugin extends Plugin { /** * Whether the auth plugin is available given the current configuration */ - isAvailable(authHandlers: string[], authConfig: AuthConfigMap): boolean; + isAvailable: (authHandlers: string[], authConfig: AuthConfigMap) => boolean; } export function isAuthPlugin(plugin: PluginModule): plugin is AuthPlugin { diff --git a/packages/redux/src/store.ts b/packages/redux/src/store.ts index 3dc63975b6..171d189153 100644 --- a/packages/redux/src/store.ts +++ b/packages/redux/src/store.ts @@ -77,8 +77,8 @@ export type WorkspaceStorageLoadOptions = { }; export interface WorkspaceStorage { - load(options?: WorkspaceStorageLoadOptions): Promise; - save(workspace: Workspace): Promise; + load: (options?: WorkspaceStorageLoadOptions) => Promise; + save: (workspace: Workspace) => Promise; } export type RootState = { diff --git a/packages/storage/src/Storage.ts b/packages/storage/src/Storage.ts index a580a17139..a0c9f3e6ab 100644 --- a/packages/storage/src/Storage.ts +++ b/packages/storage/src/Storage.ts @@ -24,19 +24,19 @@ export type SortConfig = { export type IndexRange = number[]; export interface Storage { - getTable(): Promise>; - close(): void; + getTable: () => Promise>; + close: () => void; } export interface StorageTable { - getViewportData(): Promise>; - getSnapshot(sortedRanges: IndexRange[]): Promise>; - setViewport(viewport: StorageTableViewport): void; - setFilters(config: FilterConfig[] | null): void; - setSorts(config: SortConfig[] | null): void; - setReversed(isReversed: boolean): void; - close(): void; - onUpdate(callback: ViewportUpdateCallback): StorageListenerRemover; + getViewportData: () => Promise>; + getSnapshot: (sortedRanges: IndexRange[]) => Promise>; + setViewport: (viewport: StorageTableViewport) => void; + setFilters: (config: FilterConfig[] | null) => void; + setSorts: (config: SortConfig[] | null) => void; + setReversed: (isReversed: boolean) => void; + close: () => void; + onUpdate: (callback: ViewportUpdateCallback) => StorageListenerRemover; size: number; } diff --git a/tests/utils.ts b/tests/utils.ts index 6cdd00ef6b..92d0e14d13 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -161,7 +161,10 @@ export async function pasteInMonaco( * @param page */ -export async function waitForLoadingDone(page: Page, tableNumber = 0) { +export async function waitForLoadingDone( + page: Page, + tableNumber = 0 +): Promise { await expect( page .locator('.iris-grid') @@ -188,7 +191,7 @@ export async function dragComponent( targetIndicator: Locator, offsetY = 0, steps = 100 -) { +): Promise { const page = element.page(); const destinationPos = await target.boundingBox(); if (destinationPos === null) throw new Error('element not found'); From 41bd916fc38d002e9084089ba266093b32d758bd Mon Sep 17 00:00:00 2001 From: georgecwan Date: Fri, 20 Oct 2023 11:40:05 -0700 Subject: [PATCH 2/6] Fix function parameter types --- .../code-studio/src/styleguide/MockIrisGridTreeModel.ts | 7 +++++-- packages/grid/src/MockGridModel.ts | 7 +++++-- packages/iris-grid/src/IrisGridModel.ts | 4 ++-- .../VisibilityOrderingItem.tsx | 9 ++++++--- .../sortable-tree/SortableTree.tsx | 2 ++ .../sortable-tree/SortableTreeInner.tsx | 2 ++ .../sortable-tree/TreeItem.tsx | 6 +++--- packages/pouch-storage/src/PouchStorageTable.ts | 5 ++--- 8 files changed, 27 insertions(+), 15 deletions(-) diff --git a/packages/code-studio/src/styleguide/MockIrisGridTreeModel.ts b/packages/code-studio/src/styleguide/MockIrisGridTreeModel.ts index af8cae38a3..111ca875fd 100644 --- a/packages/code-studio/src/styleguide/MockIrisGridTreeModel.ts +++ b/packages/code-studio/src/styleguide/MockIrisGridTreeModel.ts @@ -79,7 +79,7 @@ class MockIrisGridTreeModel return this.isEditable; } - setValues(edits: EditOperation[]): never { + setValues(edits: readonly EditOperation[]): never { throw new Error('Method not implemented.'); } @@ -259,7 +259,10 @@ class MockIrisGridTreeModel ); } - async setValueForRanges(ranges: GridRange[], text: string): Promise { + async setValueForRanges( + ranges: readonly GridRange[], + text: string + ): Promise { GridRange.forEachCell(ranges, (x, y) => { this.setValueForCell(x, y, text); }); diff --git a/packages/grid/src/MockGridModel.ts b/packages/grid/src/MockGridModel.ts index 6c04e9d557..afaab6e700 100644 --- a/packages/grid/src/MockGridModel.ts +++ b/packages/grid/src/MockGridModel.ts @@ -120,13 +120,16 @@ class MockGridModel extends GridModel implements EditableGridModel { this.editedData[column][row] = `${value}`; } - async setValueForRanges(ranges: GridRange[], text: string): Promise { + async setValueForRanges( + ranges: readonly GridRange[], + text: string + ): Promise { GridRange.forEachCell(ranges, (x, y) => { this.setValueForCell(x, y, text); }); } - async setValues(edits: EditOperation[]): Promise { + async setValues(edits: readonly EditOperation[]): Promise { for (let i = 0; i < edits.length; i += 1) { const edit = edits[i]; this.setValueForCell( diff --git a/packages/iris-grid/src/IrisGridModel.ts b/packages/iris-grid/src/IrisGridModel.ts index 8c09d7b882..02acb19eb3 100644 --- a/packages/iris-grid/src/IrisGridModel.ts +++ b/packages/iris-grid/src/IrisGridModel.ts @@ -5,6 +5,7 @@ import { DataBarOptions, GridModel, GridRange, + GridThemeType, ModelIndex, MoveOperation, VisibleIndex, @@ -31,7 +32,6 @@ import { PendingDataErrorMap, } from './CommonTypes'; import ColumnHeaderGroup from './ColumnHeaderGroup'; -import { IrisGridThemeType } from './IrisGridTheme'; type IrisGridModelEventNames = (typeof IrisGridModel.EVENT)[keyof typeof IrisGridModel.EVENT]; @@ -542,7 +542,7 @@ abstract class IrisGridModel< dataBarOptionsForCell( column: number, row: number, - theme: IrisGridThemeType + theme: GridThemeType ): DataBarOptions { throw new Error('Method not implemented.'); } diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx index 026162380f..fcd7785c86 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx @@ -14,7 +14,10 @@ type VisibilityOrderingItemProps = { childCount: number; item: FlattenedIrisGridTreeItem; onVisibilityChange: (modelIndexes: number[], isVisible: boolean) => void; - onClick: (name: string, event: React.MouseEvent) => void; + onClick: ( + name: string, + event: React.MouseEvent + ) => void; onGroupDelete: (group: ColumnHeaderGroup) => void; onGroupColorChange: ( group: ColumnHeaderGroup, @@ -22,7 +25,7 @@ type VisibilityOrderingItemProps = { ) => void; onGroupNameChange: (group: ColumnHeaderGroup, name: string) => void; validateGroupName: (name: string) => string; - handleProps: Record; + handleProps?: Record; }; function emptyOnClick(): void { @@ -60,7 +63,7 @@ const VisibilityOrderingItem = forwardRef< ); const handleClick = useCallback( - (event: React.MouseEvent) => { + (event: React.MouseEvent) => { onClick(value, event); }, [onClick, value] diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx index dda9a5368a..11038dc646 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx @@ -50,6 +50,8 @@ interface Props { childCount?: number; value: string; item: FlattenedItem; + ref: React.Ref | null; + handleProps?: Record; }) => JSX.Element; } diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx index 4bcfd73f96..c7efb976f6 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx @@ -85,6 +85,8 @@ interface Props { childCount?: number; value: string; item: FlattenedItem; + ref: React.Ref | null; + handleProps?: Record; }) => JSX.Element; activeId: string | null; overId: string | null; diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx index 9025631033..1b2b1396b3 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/TreeItem.tsx @@ -10,7 +10,7 @@ export interface Props { depth: number; disableInteraction?: boolean; ghost?: boolean; - handleProps?: unknown; + handleProps?: Record; value: string; item: FlattenedItem; dragRef?: React.Ref | null; @@ -21,7 +21,7 @@ export interface Props { childCount?: number; value: string; item: FlattenedItem; - handleProps: unknown; + handleProps?: Record; }) => JSX.Element; } @@ -31,7 +31,7 @@ export type TreeItemRenderFn = (props: { childCount?: number; value: string; item: T extends TreeItemType ? FlattenedItem : FlattenedItem; - handleProps: Record; + handleProps?: Record; }) => JSX.Element; export function TreeItem(props: Props): JSX.Element { diff --git a/packages/pouch-storage/src/PouchStorageTable.ts b/packages/pouch-storage/src/PouchStorageTable.ts index ecaab72936..eb6804103f 100644 --- a/packages/pouch-storage/src/PouchStorageTable.ts +++ b/packages/pouch-storage/src/PouchStorageTable.ts @@ -17,6 +17,7 @@ import { StorageSnapshot, ViewportData, ViewportUpdateCallback, + IndexRange, } from '@deephaven/storage'; import { CancelablePromise, OnlyOneProp, PromiseUtils } from '@deephaven/utils'; @@ -426,9 +427,7 @@ export class PouchStorageTable return item; } - async getSnapshot( - sortedRanges: [number, number][] - ): Promise> { + async getSnapshot(sortedRanges: IndexRange[]): Promise> { const itemMap = new Map(); const sort: PouchDBSort = [{ id: this.currentReverse ? 'desc' : 'asc' }]; From 7e2ce8da454d84774d498d6b6763d08954bd012c Mon Sep 17 00:00:00 2001 From: georgecwan Date: Mon, 23 Oct 2023 13:41:08 -0700 Subject: [PATCH 3/6] Update SortableTree types --- .../visibility-ordering-builder/VisibilityOrderingItem.tsx | 7 ++----- .../sortable-tree/SortableTree.tsx | 2 +- .../sortable-tree/SortableTreeInner.tsx | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx index fcd7785c86..2624d08f05 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/VisibilityOrderingItem.tsx @@ -14,10 +14,7 @@ type VisibilityOrderingItemProps = { childCount: number; item: FlattenedIrisGridTreeItem; onVisibilityChange: (modelIndexes: number[], isVisible: boolean) => void; - onClick: ( - name: string, - event: React.MouseEvent - ) => void; + onClick: (name: string, event: React.MouseEvent) => void; onGroupDelete: (group: ColumnHeaderGroup) => void; onGroupColorChange: ( group: ColumnHeaderGroup, @@ -63,7 +60,7 @@ const VisibilityOrderingItem = forwardRef< ); const handleClick = useCallback( - (event: React.MouseEvent) => { + (event: React.MouseEvent) => { onClick(value, event); }, [onClick, value] diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx index 11038dc646..6cc1c7f56e 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTree.tsx @@ -50,7 +50,7 @@ interface Props { childCount?: number; value: string; item: FlattenedItem; - ref: React.Ref | null; + ref: React.Ref; handleProps?: Record; }) => JSX.Element; } diff --git a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx index c7efb976f6..f91f782ce5 100644 --- a/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx +++ b/packages/iris-grid/src/sidebar/visibility-ordering-builder/sortable-tree/SortableTreeInner.tsx @@ -85,7 +85,7 @@ interface Props { childCount?: number; value: string; item: FlattenedItem; - ref: React.Ref | null; + ref: React.Ref; handleProps?: Record; }) => JSX.Element; activeId: string | null; From 467e85581691825bddfb1ed60873b05882508641 Mon Sep 17 00:00:00 2001 From: georgecwan Date: Mon, 23 Oct 2023 14:20:50 -0700 Subject: [PATCH 4/6] Fix method declarations in components package --- packages/components/src/AutoCompleteInput.tsx | 4 +-- packages/components/src/ComboBox.tsx | 4 +-- packages/components/src/CustomTimeSelect.tsx | 6 ++--- packages/components/src/DateInput.tsx | 6 ++--- packages/components/src/DateTimeInput.tsx | 8 +++--- .../components/src/DebouncedSearchInput.tsx | 2 +- .../src/HierarchicalCheckboxMenu.tsx | 2 +- packages/components/src/ItemList.tsx | 8 +++--- packages/components/src/ItemListItem.tsx | 26 +++++++++---------- packages/components/src/MaskedInput.tsx | 14 +++++----- packages/components/src/SelectValueList.tsx | 4 +-- packages/components/src/TimeInput.tsx | 8 +++--- packages/components/src/TimeSlider.tsx | 8 +++--- .../src/context-actions/ContextActionUtils.ts | 2 +- .../src/context-actions/ContextMenu.tsx | 8 +++--- .../src/context-actions/ContextMenuItem.tsx | 8 +++--- .../src/menu-actions/DropdownMenu.tsx | 4 +-- packages/components/src/menu-actions/Menu.tsx | 6 ++--- .../src/console-history/ConsoleHistory.tsx | 4 +-- 19 files changed, 66 insertions(+), 66 deletions(-) diff --git a/packages/components/src/AutoCompleteInput.tsx b/packages/components/src/AutoCompleteInput.tsx index 0f86c96d9f..e44a1a1ef7 100644 --- a/packages/components/src/AutoCompleteInput.tsx +++ b/packages/components/src/AutoCompleteInput.tsx @@ -41,13 +41,13 @@ interface AutoCompleteOption { interface AutoCompleteInputProps { options: AutoCompleteOption[]; popperOptions: PopperOptions; - onChange(value: string, isValid: boolean): void; + onChange: (value: string, isValid: boolean) => void; inputPlaceholder: string; disabled: boolean; className: string; defaultTitle: string; spellCheck: boolean; - onEnter(): void; + onEnter: () => void; noMatchText: string; 'data-testid'?: string; } diff --git a/packages/components/src/ComboBox.tsx b/packages/components/src/ComboBox.tsx index 69815d1cc1..c351360988 100644 --- a/packages/components/src/ComboBox.tsx +++ b/packages/components/src/ComboBox.tsx @@ -32,14 +32,14 @@ interface ComboBoxOption { interface ComboBoxProps { options: ComboBoxOption[]; popperOptions: PopperOptions; - onChange(value: string): void; + onChange: (value: string) => void; inputPlaceholder: string; searchPlaceholder: string; disabled: boolean; className: string; defaultValue: string; spellCheck: boolean; - onEnter(): void; + onEnter: () => void; 'data-testid'?: string; } diff --git a/packages/components/src/CustomTimeSelect.tsx b/packages/components/src/CustomTimeSelect.tsx index 84241a45ff..ef4baaebd8 100644 --- a/packages/components/src/CustomTimeSelect.tsx +++ b/packages/components/src/CustomTimeSelect.tsx @@ -19,15 +19,15 @@ type CustomTimeSelectProps = { options: { title: string; value: number }[]; popperOptions: PopperOptions; value: number | null; - onChange(value: number): void; + onChange: (value: number) => void; disabled: boolean; icon: IconDefinition; placeholder: string; customText: string; // Defaults to converting the value in milliseconds to time in seconds - valueToTime(val: number | null): number; + valueToTime: (val: number | null) => number; // Defaults to converting the time in seconds to value in milliseconds - timeToValue(time: number): number; + timeToValue: (time: number) => number; invalid: boolean; 'data-testid'?: string; }; diff --git a/packages/components/src/DateInput.tsx b/packages/components/src/DateInput.tsx index ec5d4d4845..2f368757e6 100644 --- a/packages/components/src/DateInput.tsx +++ b/packages/components/src/DateInput.tsx @@ -12,10 +12,10 @@ const DATE_FORMAT = 'YYYY-MM-DD'; type DateInputProps = { className?: string; - onChange?(date?: string): void; + onChange?: (date?: string) => void; defaultValue?: string; - onFocus?(): void; - onBlur?(): void; + onFocus?: () => void; + onBlur?: () => void; 'data-testid'?: string; }; diff --git a/packages/components/src/DateTimeInput.tsx b/packages/components/src/DateTimeInput.tsx index ddb10053cb..cd22d76920 100644 --- a/packages/components/src/DateTimeInput.tsx +++ b/packages/components/src/DateTimeInput.tsx @@ -20,11 +20,11 @@ const FULL_DATE_FORMAT = 'YYYY-MM-DD HH:MM:SS.SSSSSSSSS'; type DateTimeInputProps = { className?: string; - onChange?(value?: string): void; + onChange?: (value?: string) => void; defaultValue?: string; - onFocus?(): void; - onBlur?(): void; - onSubmit?(event?: KeyboardEvent): void; + onFocus?: () => void; + onBlur?: () => void; + onSubmit?: (event?: KeyboardEvent) => void; 'data-testid'?: string; }; diff --git a/packages/components/src/DebouncedSearchInput.tsx b/packages/components/src/DebouncedSearchInput.tsx index 5c746391bd..2b8569c704 100644 --- a/packages/components/src/DebouncedSearchInput.tsx +++ b/packages/components/src/DebouncedSearchInput.tsx @@ -5,7 +5,7 @@ import SearchInput from './SearchInput'; interface DebouncedSearchInputProps { value: string; placeholder: string; - onChange(value: string): void; + onChange: (value: string) => void; className: string; matchCount: number; debounceMs: number; diff --git a/packages/components/src/HierarchicalCheckboxMenu.tsx b/packages/components/src/HierarchicalCheckboxMenu.tsx index 3a5159e6a2..63b4bbdefa 100644 --- a/packages/components/src/HierarchicalCheckboxMenu.tsx +++ b/packages/components/src/HierarchicalCheckboxMenu.tsx @@ -16,7 +16,7 @@ type HierarchicalCheckboxMenuProps = { className: string; menuText: string; valueMap: HierarchicalCheckboxValueMap; - onUpdateValueMap(map: HierarchicalCheckboxValueMap): void; + onUpdateValueMap: (map: HierarchicalCheckboxValueMap) => void; icon: IconDefinition | null; id: string; 'data-testid'?: string; diff --git a/packages/components/src/ItemList.tsx b/packages/components/src/ItemList.tsx index ca61a2072b..ed4364d2d9 100644 --- a/packages/components/src/ItemList.tsx +++ b/packages/components/src/ItemList.tsx @@ -58,12 +58,12 @@ export type ItemListProps = { // Set to true if you want the list to scroll when new items are added and it's already at the bottom isStickyBottom: boolean; // Fired when an item gets focused - onFocusChange(index: number | null): void; + onFocusChange: (index: number | null) => void; // Fired when an item is clicked. With multiple selection, fired on double click. - onSelect(index: number, event: React.SyntheticEvent): void; - onSelectionChange(ranges: readonly Range[]): void; - onViewportChange(topRow: number, bottomRow: number): void; + onSelect: (index: number, event: React.SyntheticEvent) => void; + onSelectionChange: (ranges: readonly Range[]) => void; + onViewportChange: (topRow: number, bottomRow: number) => void; overscanCount: number; selectedRanges: readonly Range[]; disableSelect: boolean; diff --git a/packages/components/src/ItemListItem.tsx b/packages/components/src/ItemListItem.tsx index 0723dafa21..366a2f8d13 100644 --- a/packages/components/src/ItemListItem.tsx +++ b/packages/components/src/ItemListItem.tsx @@ -12,19 +12,19 @@ interface ItemListItemProps { itemIndex: number; // eslint-disable-next-line react/no-unused-prop-types disableSelect: boolean; - onBlur(index: number, e: React.FocusEvent): void; - onClick(index: number, e: React.MouseEvent): void; - onContextMenu(index: number, e: React.MouseEvent): void; - onDragStart(index: number, e: React.DragEvent): void; - onDrag(index: number, e: React.DragEvent): void; - onDragOver(index: number, e: React.DragEvent): void; - onDragEnd(index: number, e: React.DragEvent): void; - onDrop(index: number, e: React.DragEvent): void; - onDoubleClick(index: number, e: React.MouseEvent): void; - onFocus(index: number, e: React.FocusEvent): void; - onMouseDown(index: number, e: React.MouseEvent): void; - onMouseMove(index: number, e: React.MouseEvent): void; - onMouseUp(index: number, e: React.MouseEvent): void; + onBlur: (index: number, e: React.FocusEvent) => void; + onClick: (index: number, e: React.MouseEvent) => void; + onContextMenu: (index: number, e: React.MouseEvent) => void; + onDragStart: (index: number, e: React.DragEvent) => void; + onDrag: (index: number, e: React.DragEvent) => void; + onDragOver: (index: number, e: React.DragEvent) => void; + onDragEnd: (index: number, e: React.DragEvent) => void; + onDrop: (index: number, e: React.DragEvent) => void; + onDoubleClick: (index: number, e: React.MouseEvent) => void; + onFocus: (index: number, e: React.FocusEvent) => void; + onMouseDown: (index: number, e: React.MouseEvent) => void; + onMouseMove: (index: number, e: React.MouseEvent) => void; + onMouseUp: (index: number, e: React.MouseEvent) => void; style: React.CSSProperties; children: React.ReactNode; 'data-testid'?: string; diff --git a/packages/components/src/MaskedInput.tsx b/packages/components/src/MaskedInput.tsx index 03a6397f08..2b045a805f 100644 --- a/packages/components/src/MaskedInput.tsx +++ b/packages/components/src/MaskedInput.tsx @@ -43,25 +43,25 @@ type MaskedInputProps = { /** The current selection to use for the input */ selection?: SelectionSegment; /** Called when the value changes. Note the value may still be incomplete. */ - onChange?(value: string): void; + onChange?: (value: string) => void; /** Called when selection changes */ - onSelect?(segment: SelectionSegment): void; + onSelect?: (segment: SelectionSegment) => void; /** Called when enter is pressed */ - onSubmit?(event?: KeyboardEvent): void; + onSubmit?: (event?: KeyboardEvent) => void; /** Retrieve the next value for a provided segment */ - getNextSegmentValue?( + getNextSegmentValue?: ( segment: SelectionSegment, delta: number, segmentValue: string, value: string - ): string; - getPreferredReplacementString?( + ) => string; + getPreferredReplacementString?: ( value: string, replaceIndex: number, replaceChar: string, selectionStart: number, selectionEnd: number - ): string; + ) => string; onFocus?: React.FocusEventHandler; onBlur?: React.FocusEventHandler; diff --git a/packages/components/src/SelectValueList.tsx b/packages/components/src/SelectValueList.tsx index 38c0f3c46d..e2ab008767 100644 --- a/packages/components/src/SelectValueList.tsx +++ b/packages/components/src/SelectValueList.tsx @@ -23,8 +23,8 @@ type SelectValueListProps = { items: SelectItem[]; onBlur?: React.FocusEventHandler; - onSelect(itemIndex: number, value: T | null): void; - onViewportChange(topRow: number, bottomRow: number): void; + onSelect: (itemIndex: number, value: T | null) => void; + onViewportChange: (topRow: number, bottomRow: number) => void; 'data-testid'?: string; }; diff --git a/packages/components/src/TimeInput.tsx b/packages/components/src/TimeInput.tsx index 49407b8c5f..f75a647006 100644 --- a/packages/components/src/TimeInput.tsx +++ b/packages/components/src/TimeInput.tsx @@ -20,11 +20,11 @@ const EXAMPLES = ['00:00:00', '12:34:56', '23:59:59']; type TimeInputProps = { allowValueWrapping?: boolean; className?: string; - onChange?(timeInSec: number): void; - onSelect?(selection: SelectionSegment): void; + onChange?: (timeInSec: number) => void; + onSelect?: (selection: SelectionSegment) => void; value?: number; - onFocus?(): void; - onBlur?(): void; + onFocus?: () => void; + onBlur?: () => void; 'data-testid'?: string; }; diff --git a/packages/components/src/TimeSlider.tsx b/packages/components/src/TimeSlider.tsx index c54c636923..3979471386 100644 --- a/packages/components/src/TimeSlider.tsx +++ b/packages/components/src/TimeSlider.tsx @@ -21,7 +21,7 @@ const SNAP_NEAREST_MINUTES = 5 * 60; // rounds in 5 minute intervals type TimeSliderProps = { startTime: number; endTime: number; - onChange(value: { startTime: number; endTime: number }): void; + onChange: (value: { startTime: number; endTime: number }) => void; isStartModified?: boolean; isEndModified?: boolean; 'data-testid'?: string; @@ -130,8 +130,8 @@ function TimeSlider({ type PopOversProps = { startTime: number; endTime: number; - onStartTimeChange(time: number): void; - onEndTimeChange(time: number): void; + onStartTimeChange: (time: number) => void; + onEndTimeChange: (time: number) => void; isStartModified: boolean; isEndModified: boolean; 'data-testid'?: string; @@ -311,7 +311,7 @@ function TrackFills(props: TrackFillsProps): JSX.Element { type HandleProps = { track: React.RefObject; time: number; - setTime(time: number): void; + setTime: (time: number) => void; 'data-testid'?: string; }; diff --git a/packages/components/src/context-actions/ContextActionUtils.ts b/packages/components/src/context-actions/ContextActionUtils.ts index 03ed4f7ef1..353c13bff1 100644 --- a/packages/components/src/context-actions/ContextActionUtils.ts +++ b/packages/components/src/context-actions/ContextActionUtils.ts @@ -12,7 +12,7 @@ export type MenuItem = ContextAction | Promise; export interface ContextAction { title?: string; description?: string; - action?(event?: Event): void; + action?: (event?: Event) => void; actions?: ResolvableContextAction[]; icon?: IconDefinition | React.ReactElement; iconColor?: string; diff --git a/packages/components/src/context-actions/ContextMenu.tsx b/packages/components/src/context-actions/ContextMenu.tsx index 879743c729..32448f88c2 100644 --- a/packages/components/src/context-actions/ContextMenu.tsx +++ b/packages/components/src/context-actions/ContextMenu.tsx @@ -14,15 +14,15 @@ const log = Log.module('ContextMenu'); interface ContextMenuProps { top: number; left: number; - updatePosition(top: number, left: number): void; + updatePosition: (top: number, left: number) => void; // only submenus will have these, defaults to 0 otherwise // represents the width height of the parent menu item subMenuParentWidth: number; subMenuParentHeight: number; actions: ResolvableContextAction[]; - closeMenu(closeAll: boolean): void; - onMenuClosed(menu: ContextMenu): void; - onMenuOpened(menu: ContextMenu): void; + closeMenu: (closeAll: boolean) => void; + onMenuClosed: (menu: ContextMenu) => void; + onMenuOpened: (menu: ContextMenu) => void; options: { doNotVerifyPosition?: boolean; separateKeyboardMouse?: boolean; diff --git a/packages/components/src/context-actions/ContextMenuItem.tsx b/packages/components/src/context-actions/ContextMenuItem.tsx index 07e78f476f..febf5c72ab 100644 --- a/packages/components/src/context-actions/ContextMenuItem.tsx +++ b/packages/components/src/context-actions/ContextMenuItem.tsx @@ -6,13 +6,13 @@ import type { ContextAction } from './ContextActionUtils'; interface ContextMenuItemProps { children?: React.ReactNode; - closeMenu(closeAll: boolean): void; + closeMenu: (closeAll: boolean) => void; isKeyboardSelected?: boolean; isMouseSelected?: boolean; menuItem: ContextAction; - onMenuItemClick(item: ContextAction, e: React.MouseEvent): void; - onMenuItemMouseMove(item: ContextAction, e: React.MouseEvent): void; - onMenuItemContextMenu(item: ContextAction, e: React.MouseEvent): void; + onMenuItemClick: (item: ContextAction, e: React.MouseEvent) => void; + onMenuItemMouseMove: (item: ContextAction, e: React.MouseEvent) => void; + onMenuItemContextMenu: (item: ContextAction, e: React.MouseEvent) => void; 'data-testid'?: string; } diff --git a/packages/components/src/menu-actions/DropdownMenu.tsx b/packages/components/src/menu-actions/DropdownMenu.tsx index 68397b77e3..fc7586981d 100644 --- a/packages/components/src/menu-actions/DropdownMenu.tsx +++ b/packages/components/src/menu-actions/DropdownMenu.tsx @@ -47,8 +47,8 @@ type DropdownMenuProps = { // Override to prevent nested lists actions: DropdownActions; isShown: boolean | null; - onMenuClosed(): void; - onMenuOpened(): void; + onMenuClosed: () => void; + onMenuOpened: () => void; options: MenuOptions; popperOptions: PopperOptions; popperClassName: string; diff --git a/packages/components/src/menu-actions/Menu.tsx b/packages/components/src/menu-actions/Menu.tsx index 4c5f376e45..359612febf 100644 --- a/packages/components/src/menu-actions/Menu.tsx +++ b/packages/components/src/menu-actions/Menu.tsx @@ -12,9 +12,9 @@ export type MenuOptions = { type MenuProps = { actions: (() => ContextAction[]) | ContextAction | ContextAction[]; - closeMenu(closeAll: boolean): void; - onMenuClosed(menu: Menu): void; - onMenuOpened(menu: Menu): void; + closeMenu: (closeAll: boolean) => void; + onMenuClosed: (menu: Menu) => void; + onMenuOpened: (menu: Menu) => void; options: MenuOptions; menuStyle: React.CSSProperties; 'data-testid'?: string; diff --git a/packages/console/src/console-history/ConsoleHistory.tsx b/packages/console/src/console-history/ConsoleHistory.tsx index 4d5a8f22ba..46664bbee3 100644 --- a/packages/console/src/console-history/ConsoleHistory.tsx +++ b/packages/console/src/console-history/ConsoleHistory.tsx @@ -13,8 +13,8 @@ interface ConsoleHistoryProps { language: string; openObject: (object: VariableDefinition) => void; disabled?: boolean; - supportsType(type: string): boolean; - iconForType(type: string): ReactElement; + supportsType: (type: string) => boolean; + iconForType: (type: string) => ReactElement; } function itemKey(i: number, item: ConsoleHistoryActionItem): string { From 57d6fdd0f4173a3e9d54b49950f0a84fa1c844c8 Mon Sep 17 00:00:00 2001 From: georgecwan Date: Tue, 24 Oct 2023 10:11:20 -0700 Subject: [PATCH 5/6] Fix menu action handlers --- .../code-studio/src/main/AppControlsMenu.tsx | 10 +++--- .../code-studio/src/main/AppMainContainer.tsx | 2 +- .../code-studio/src/styleguide/Dialog.tsx | 2 +- .../src/styleguide/DraggableListInput.tsx | 4 +-- .../src/styleguide/DraggableLists.tsx | 7 ++-- .../code-studio/src/styleguide/Inputs.tsx | 1 - packages/components/src/DragUtils.ts | 6 ++-- packages/components/src/DraggableItemList.tsx | 2 +- packages/components/src/EditableItemList.tsx | 4 +-- .../src/context-actions/ContextActionUtils.ts | 2 +- .../src/context-actions/ContextMenu.tsx | 2 +- packages/components/src/menu-actions/Menu.tsx | 2 +- packages/console/src/Console.tsx | 34 +++++++++++-------- .../src/command-history/CommandHistory.tsx | 4 +-- .../AdvancedFilterCreatorSelectValueList.tsx | 4 +-- packages/iris-grid/src/GotoRow.tsx | 4 +-- packages/iris-grid/src/sidebar/RollupRows.tsx | 10 +++--- 17 files changed, 55 insertions(+), 45 deletions(-) diff --git a/packages/code-studio/src/main/AppControlsMenu.tsx b/packages/code-studio/src/main/AppControlsMenu.tsx index 2743953c3a..17d7355ea8 100644 --- a/packages/code-studio/src/main/AppControlsMenu.tsx +++ b/packages/code-studio/src/main/AppControlsMenu.tsx @@ -138,7 +138,7 @@ function DragSourceMenuItem(props: DragSourceMenuItemProps): JSX.Element { } interface AppControlsMenuProps { - handleControlSelect: (type: string, event?: KeyboardEvent) => void; + handleControlSelect: (type: string, event: Event) => void; handleToolSelect: (type: string) => void; onClearFilter: () => void; } @@ -151,7 +151,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement { title: 'Input Filter', icon: dhInput, menuElement: , - action: (dragEvent?: KeyboardEvent) => { + action: (dragEvent: Event) => { handleControlSelect(ControlType.INPUT_FILTER, dragEvent); }, order: 10, @@ -160,7 +160,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement { title: 'Dropdown Filter', icon: dhTriangleDownSquare, menuElement: , - action: (dragEvent?: KeyboardEvent) => { + action: (dragEvent: Event) => { handleControlSelect(ControlType.DROPDOWN_FILTER, dragEvent); }, order: 15, @@ -169,7 +169,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement { title: 'Markdown Widget', icon: vsMarkdown, menuElement: , - action: (dragEvent?: KeyboardEvent) => { + action: (dragEvent: Event) => { handleControlSelect(ControlType.MARKDOWN, dragEvent); }, order: 20, @@ -178,7 +178,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement { title: 'Filter Sets', icon: vsDeviceCamera, menuElement: , - action: (dragEvent?: KeyboardEvent) => { + action: (dragEvent: Event) => { handleControlSelect(ControlType.FILTER_SET_MANAGER, dragEvent); }, order: 25, diff --git a/packages/code-studio/src/main/AppMainContainer.tsx b/packages/code-studio/src/main/AppMainContainer.tsx index c4b5b8a057..da7f7a2609 100644 --- a/packages/code-studio/src/main/AppMainContainer.tsx +++ b/packages/code-studio/src/main/AppMainContainer.tsx @@ -361,7 +361,7 @@ export class AppMainContainer extends Component< this.setState({ isSettingsMenuShown: true }); } - handleControlSelect(type: string, dragEvent?: KeyboardEvent): void { + handleControlSelect(type: string, dragEvent: Event): void { log.debug('handleControlSelect', type); switch (type) { diff --git a/packages/code-studio/src/styleguide/Dialog.tsx b/packages/code-studio/src/styleguide/Dialog.tsx index 497b20beb7..5b7b7c9233 100644 --- a/packages/code-studio/src/styleguide/Dialog.tsx +++ b/packages/code-studio/src/styleguide/Dialog.tsx @@ -54,7 +54,7 @@ class Dialog extends Component { } handleUpdateCheckboxMap( - checkBoxMap: Map> + checkBoxMap: Map> ): void { this.setState({ checkBoxMap, diff --git a/packages/code-studio/src/styleguide/DraggableListInput.tsx b/packages/code-studio/src/styleguide/DraggableListInput.tsx index 360e4f52ac..b3f4ff5278 100644 --- a/packages/code-studio/src/styleguide/DraggableListInput.tsx +++ b/packages/code-studio/src/styleguide/DraggableListInput.tsx @@ -12,7 +12,7 @@ interface DraggableListInputProps { isDropDisabled: boolean; isMultiSelect: boolean; items: Array; - onSelectionChange: (listSelectedRanges: Range[]) => void; + onSelectionChange: (listSelectedRanges: readonly Range[]) => void; selectedRanges: Range[]; } interface DraggableListInputState { @@ -73,7 +73,7 @@ class DraggableListInput extends PureComponent< } } - handleSelectionChange(selectedRanges: Array): void { + handleSelectionChange(selectedRanges: readonly Range[]): void { console.log('Selection changed', selectedRanges); const { onSelectionChange } = this.props; diff --git a/packages/code-studio/src/styleguide/DraggableLists.tsx b/packages/code-studio/src/styleguide/DraggableLists.tsx index b1930d0f95..ff67dad9a4 100644 --- a/packages/code-studio/src/styleguide/DraggableLists.tsx +++ b/packages/code-studio/src/styleguide/DraggableLists.tsx @@ -146,10 +146,13 @@ class DraggableLists extends Component< ); } - handleSelectionChange(listIndex: number, listSelectedRanges: Range[]): void { + handleSelectionChange( + listIndex: number, + listSelectedRanges: readonly Range[] + ): void { this.setState(({ selectedRanges }) => { const newSelectedRanges = [...selectedRanges]; - newSelectedRanges[listIndex] = listSelectedRanges; + newSelectedRanges[listIndex] = [...listSelectedRanges]; return { selectedRanges: newSelectedRanges }; }); } diff --git a/packages/code-studio/src/styleguide/Inputs.tsx b/packages/code-studio/src/styleguide/Inputs.tsx index e5a55ea0ba..e73cf5b435 100644 --- a/packages/code-studio/src/styleguide/Inputs.tsx +++ b/packages/code-studio/src/styleguide/Inputs.tsx @@ -342,7 +342,6 @@ function Inputs(): React.ReactElement { onChange={setCustomTimeValue} customText="Custom Timeout" placeholder="Select a timeout" - valueToTime={(value: number) => Math.round(value / 1000)} timeToValue={time => time * 1000} /> diff --git a/packages/components/src/DragUtils.ts b/packages/components/src/DragUtils.ts index 2158f016f7..7951c691c1 100644 --- a/packages/components/src/DragUtils.ts +++ b/packages/components/src/DragUtils.ts @@ -13,7 +13,7 @@ class DragUtils { */ static reorder( sourceList: T[], - selectedRanges: Range[], + selectedRanges: readonly Range[], destinationList: T[], destinationIndex: number ): T[] { @@ -32,7 +32,7 @@ class DragUtils { * @param ranges Array of the ranges to remove. * @returns The removed items, in the order of the ranges removed. */ - static removeItems(list: T[], ranges: Range[]): T[] { + static removeItems(list: T[], ranges: readonly Range[]): T[] { const items = []; // Sort them in reverse, so we don't screw up the range indexes @@ -56,7 +56,7 @@ class DragUtils { */ static adjustDestinationIndex( destinationIndex: number, - ranges: Range[] + ranges: readonly Range[] ): number { let adjustedIndex = destinationIndex; for (let i = 0; i < ranges.length; i += 1) { diff --git a/packages/components/src/DraggableItemList.tsx b/packages/components/src/DraggableItemList.tsx index 57aef45e6a..41e8581395 100644 --- a/packages/components/src/DraggableItemList.tsx +++ b/packages/components/src/DraggableItemList.tsx @@ -227,7 +227,7 @@ class DraggableItemList extends PureComponent< { max: ItemList.CACHE_SIZE } ); - handleSelectionChange(selectedRanges: Range[]): void { + handleSelectionChange(selectedRanges: readonly Range[]): void { this.setState({ selectedCount: RangeUtils.count(selectedRanges) }); const { onSelectionChange } = this.props; diff --git a/packages/components/src/EditableItemList.tsx b/packages/components/src/EditableItemList.tsx index 831a994aae..1c6f448d7c 100644 --- a/packages/components/src/EditableItemList.tsx +++ b/packages/components/src/EditableItemList.tsx @@ -30,10 +30,10 @@ function EditableItemList(props: EditableItemListProps): React.ReactElement { validate = () => null, } = props; const [inputError, setInputError] = useState(null); - const [selectedRanges, setSelectedRanges] = useState([]); + const [selectedRanges, setSelectedRanges] = useState([]); const [value, setValue] = useState(''); - const handleSelectionChange = useCallback((ranges: Range[]) => { + const handleSelectionChange = useCallback((ranges: readonly Range[]) => { setSelectedRanges(ranges); }, []); diff --git a/packages/components/src/context-actions/ContextActionUtils.ts b/packages/components/src/context-actions/ContextActionUtils.ts index 353c13bff1..4e76570dea 100644 --- a/packages/components/src/context-actions/ContextActionUtils.ts +++ b/packages/components/src/context-actions/ContextActionUtils.ts @@ -12,7 +12,7 @@ export type MenuItem = ContextAction | Promise; export interface ContextAction { title?: string; description?: string; - action?: (event?: Event) => void; + action?: (event: Event) => void; actions?: ResolvableContextAction[]; icon?: IconDefinition | React.ReactElement; iconColor?: string; diff --git a/packages/components/src/context-actions/ContextMenu.tsx b/packages/components/src/context-actions/ContextMenu.tsx index 32448f88c2..b3276a78fa 100644 --- a/packages/components/src/context-actions/ContextMenu.tsx +++ b/packages/components/src/context-actions/ContextMenu.tsx @@ -516,7 +516,7 @@ class ContextMenu extends PureComponent { if (menuItem.actions != null) { this.openSubMenu(menuItems.indexOf(menuItem)); } else if (menuItem.action != null) { - menuItem.action(); + menuItem.action(e.nativeEvent); this.closeMenu(true); } } diff --git a/packages/components/src/menu-actions/Menu.tsx b/packages/components/src/menu-actions/Menu.tsx index 359612febf..c2af839d2b 100644 --- a/packages/components/src/menu-actions/Menu.tsx +++ b/packages/components/src/menu-actions/Menu.tsx @@ -227,7 +227,7 @@ class Menu extends PureComponent { (menuItem.disabled === undefined || !menuItem.disabled) && menuItem.action != null ) { - menuItem.action(); + menuItem.action(e.nativeEvent); this.closeMenu(true); } } diff --git a/packages/console/src/Console.tsx b/packages/console/src/Console.tsx index 9d0eb6571b..0edcf19086 100644 --- a/packages/console/src/Console.tsx +++ b/packages/console/src/Console.tsx @@ -8,7 +8,11 @@ import React, { ReactNode, RefObject, } from 'react'; -import { ContextActions, DropdownAction } from '@deephaven/components'; +import { + ContextActions, + DropdownAction, + ResolvableContextAction, +} from '@deephaven/components'; import { vsCheck } from '@deephaven/icons'; import classNames from 'classnames'; import memoize from 'memoize-one'; @@ -283,7 +287,7 @@ export class Console extends PureComponent { } } - handleClearShortcut(event: CustomEvent): void { + handleClearShortcut(event: Event): void { event.preventDefault(); event.stopPropagation(); @@ -408,7 +412,7 @@ export class Console extends PureComponent { }); } - handleFocusHistory(event: CustomEvent): void { + handleFocusHistory(event: Event): void { event.preventDefault(); event.stopPropagation(); @@ -889,17 +893,19 @@ export class Console extends PureComponent { ...objectMap.values(), ]); - getContextActions = memoize((actions: DropdownAction[]) => [ - ...actions, - { - action: this.handleClearShortcut, - shortcut: SHORTCUTS.CONSOLE.CLEAR, - }, - { - action: this.handleFocusHistory, - shortcut: SHORTCUTS.CONSOLE.FOCUS_HISTORY, - }, - ]); + getContextActions = memoize( + (actions: DropdownAction[]): ResolvableContextAction[] => [ + ...actions, + { + action: this.handleClearShortcut, + shortcut: SHORTCUTS.CONSOLE.CLEAR, + }, + { + action: this.handleFocusHistory, + shortcut: SHORTCUTS.CONSOLE.FOCUS_HISTORY, + }, + ] + ); addCommand(command: string, focus = true, execute = false): void { if (!this.consoleInput.current) { diff --git a/packages/console/src/command-history/CommandHistory.tsx b/packages/console/src/command-history/CommandHistory.tsx index 6047bb49ca..0d2e0e8256 100644 --- a/packages/console/src/command-history/CommandHistory.tsx +++ b/packages/console/src/command-history/CommandHistory.tsx @@ -54,7 +54,7 @@ interface CommandHistoryState { itemCount: number; items: CommandHistoryStorageItem[]; offset: number; - selectedRanges: Range[]; + selectedRanges: readonly Range[]; searchText: string; debouncedSearchText: string; } @@ -320,7 +320,7 @@ class CommandHistory extends Component< sendToConsole(name); } - handleSelectionChange(selectedRanges: Range[]): void { + handleSelectionChange(selectedRanges: readonly Range[]): void { this.setState({ selectedRanges }); this.updateActions(); } diff --git a/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx b/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx index dfd16af4bf..03feaf2f98 100644 --- a/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx +++ b/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx @@ -130,7 +130,7 @@ class AdvancedFilterCreatorSelectValueList extends PureComponent< list: SelectValueList | null; - handleSelect(itemIndex: number, value: T): void { + handleSelect(itemIndex: number, value: T | null): void { const { invertSelection } = this.props; let { selectedValues } = this.state; selectedValues = [...selectedValues]; @@ -140,7 +140,7 @@ class AdvancedFilterCreatorSelectValueList extends PureComponent< ); if (selectedIndex >= 0) { selectedValues.splice(selectedIndex, 1); - } else { + } else if (value != null) { selectedValues.push(value); } diff --git a/packages/iris-grid/src/GotoRow.tsx b/packages/iris-grid/src/GotoRow.tsx index 0907f98600..a25b5caa0a 100644 --- a/packages/iris-grid/src/GotoRow.tsx +++ b/packages/iris-grid/src/GotoRow.tsx @@ -115,9 +115,9 @@ const GotoRow = forwardRef( }; const handleGotoValueKeySubmit = ( - e: KeyboardEvent + e?: KeyboardEvent ): void => { - if (e.key === 'Enter') { + if (e?.key === 'Enter') { e.stopPropagation(); e.preventDefault(); onGotoValueSubmit(e.shiftKey); diff --git a/packages/iris-grid/src/sidebar/RollupRows.tsx b/packages/iris-grid/src/sidebar/RollupRows.tsx index 669a265df5..4e1bb43cbd 100644 --- a/packages/iris-grid/src/sidebar/RollupRows.tsx +++ b/packages/iris-grid/src/sidebar/RollupRows.tsx @@ -49,9 +49,9 @@ interface RollupRowsProps { } interface RollupRowsState { - ungroupedSelectedRanges: Range[]; + ungroupedSelectedRanges: readonly Range[]; columns: ColumnName[]; - groupedSelectedRanges: Range[]; + groupedSelectedRanges: readonly Range[]; searchFilter: string; showConstituents: boolean; showNonAggregatedColumns: boolean; @@ -333,7 +333,9 @@ class RollupRows extends Component { })); } - handleUngroupedSelectionChange(ungroupedSelectedRanges: Range[]): void { + handleUngroupedSelectionChange( + ungroupedSelectedRanges: readonly Range[] + ): void { log.debug2('handleUngroupedSelectionChange', ungroupedSelectedRanges); this.setState( ({ ungroupedSelectedRanges: stateUngroupedSelectedRanges }) => { @@ -346,7 +348,7 @@ class RollupRows extends Component { ); } - handleGroupedSelectionChange(groupedSelectedRanges: Range[]): void { + handleGroupedSelectionChange(groupedSelectedRanges: readonly Range[]): void { log.debug2('handleGroupedSelectedRanges', groupedSelectedRanges); this.setState(({ groupedSelectedRanges: stateGroupedSelectedRanges }) => { if (groupedSelectedRanges === stateGroupedSelectedRanges) { From 24edf02c998f63587947f222fb1bf0774c42dabb Mon Sep 17 00:00:00 2001 From: georgecwan Date: Thu, 26 Oct 2023 09:14:07 -0700 Subject: [PATCH 6/6] Update parameter types --- packages/code-studio/src/styleguide/Dialog.tsx | 4 +--- packages/components/src/DateTimeInput.tsx | 2 +- packages/components/src/MaskedInput.tsx | 2 +- .../src/AdvancedFilterCreatorSelectValue.tsx | 11 +++++++---- .../src/AdvancedFilterCreatorSelectValueList.tsx | 8 ++++---- packages/iris-grid/src/GotoRow.tsx | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/code-studio/src/styleguide/Dialog.tsx b/packages/code-studio/src/styleguide/Dialog.tsx index 5b7b7c9233..61dde069f0 100644 --- a/packages/code-studio/src/styleguide/Dialog.tsx +++ b/packages/code-studio/src/styleguide/Dialog.tsx @@ -53,9 +53,7 @@ class Dialog extends Component { }; } - handleUpdateCheckboxMap( - checkBoxMap: Map> - ): void { + handleUpdateCheckboxMap(checkBoxMap: HierarchicalCheckboxValueMap): void { this.setState({ checkBoxMap, }); diff --git a/packages/components/src/DateTimeInput.tsx b/packages/components/src/DateTimeInput.tsx index cd22d76920..065f066104 100644 --- a/packages/components/src/DateTimeInput.tsx +++ b/packages/components/src/DateTimeInput.tsx @@ -24,7 +24,7 @@ type DateTimeInputProps = { defaultValue?: string; onFocus?: () => void; onBlur?: () => void; - onSubmit?: (event?: KeyboardEvent) => void; + onSubmit?: (event: KeyboardEvent) => void; 'data-testid'?: string; }; diff --git a/packages/components/src/MaskedInput.tsx b/packages/components/src/MaskedInput.tsx index 2b045a805f..e5ffb4475f 100644 --- a/packages/components/src/MaskedInput.tsx +++ b/packages/components/src/MaskedInput.tsx @@ -47,7 +47,7 @@ type MaskedInputProps = { /** Called when selection changes */ onSelect?: (segment: SelectionSegment) => void; /** Called when enter is pressed */ - onSubmit?: (event?: KeyboardEvent) => void; + onSubmit?: (event: KeyboardEvent) => void; /** Retrieve the next value for a provided segment */ getNextSegmentValue?: ( segment: SelectionSegment, diff --git a/packages/iris-grid/src/AdvancedFilterCreatorSelectValue.tsx b/packages/iris-grid/src/AdvancedFilterCreatorSelectValue.tsx index 7f1fcf1f33..d85e7da713 100644 --- a/packages/iris-grid/src/AdvancedFilterCreatorSelectValue.tsx +++ b/packages/iris-grid/src/AdvancedFilterCreatorSelectValue.tsx @@ -16,10 +16,10 @@ import { ColumnName } from './CommonTypes'; interface AdvancedFilterCreatorSelectValueProps { dh: DhType; invertSelection: boolean; - selectedValues: T[]; + selectedValues: (T | null)[]; table?: Table; formatter: Formatter; - onChange: (selectedValues: T[], invertSelection: boolean) => void; + onChange: (selectedValues: (T | null)[], invertSelection: boolean) => void; showSearch: boolean; timeZone: string; } @@ -28,7 +28,7 @@ interface AdvancedFilterCreatorSelectValueState { error?: string; filters: FilterCondition[]; invertSelection: boolean; - selectedValues: T[]; + selectedValues: (T | null)[]; searchText: string; table?: Table; } @@ -179,7 +179,10 @@ class AdvancedFilterCreatorSelectValue extends PureComponent< }); } - handleListChange(selectedValues: T[], invertSelection: boolean): void { + handleListChange( + selectedValues: (T | null)[], + invertSelection: boolean + ): void { this.setState({ selectedValues, invertSelection }); const { onChange } = this.props; diff --git a/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx b/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx index 03feaf2f98..9a7bb5ee18 100644 --- a/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx +++ b/packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.tsx @@ -18,11 +18,11 @@ const log = Log.module('AdvancedFilterCreatorSelectValueList'); interface AdvancedFilterCreatorSelectValueListProps { dh: DhType; - selectedValues: T[]; + selectedValues: (T | null)[]; table?: Table; filters: FilterCondition[]; invertSelection: boolean; - onChange: (selectedValues: T[], invertSelection: boolean) => void; + onChange: (selectedValues: (T | null)[], invertSelection: boolean) => void; formatter: Formatter; } @@ -30,7 +30,7 @@ interface AdvancedFilterCreatorSelectValueListState { itemCount: number; items: SelectItem[]; offset: number; - selectedValues: T[]; + selectedValues: (T | null)[]; isLoading: boolean; } /** @@ -140,7 +140,7 @@ class AdvancedFilterCreatorSelectValueList extends PureComponent< ); if (selectedIndex >= 0) { selectedValues.splice(selectedIndex, 1); - } else if (value != null) { + } else { selectedValues.push(value); } diff --git a/packages/iris-grid/src/GotoRow.tsx b/packages/iris-grid/src/GotoRow.tsx index a25b5caa0a..0907f98600 100644 --- a/packages/iris-grid/src/GotoRow.tsx +++ b/packages/iris-grid/src/GotoRow.tsx @@ -115,9 +115,9 @@ const GotoRow = forwardRef( }; const handleGotoValueKeySubmit = ( - e?: KeyboardEvent + e: KeyboardEvent ): void => { - if (e?.key === 'Enter') { + if (e.key === 'Enter') { e.stopPropagation(); e.preventDefault(); onGotoValueSubmit(e.shiftKey);