This is an automated email from the ASF dual-hosted git repository. rusackas pushed a commit to branch chore/ts-migration-dashboard in repository https://gitbox.apache.org/repos/asf/superset.git
commit 61681dfc58d3a51252ce378af8f1c90eb2d775ce Author: Evan Rusackas <[email protected]> AuthorDate: Tue Feb 3 04:51:07 2026 +0100 refactor(frontend): remove dead type definition files and orphaned tests Remove 5 dead type files that had no imports in the codebase: - dashboard/reducers/types.ts (replaced by dashboard/types.ts) - dashboard/util/propShapes.tsx (legacy PropTypes-derived interfaces) - explore/controls/FilterControl/adhocFilterType.ts (unused) - explore/controls/MetricControl/adhocMetricType.ts (unused) - explore/controls/MetricControl/savedMetricType.ts (re-export barrel) Also remove orphaned test files and dead re-exports from types.ts. Co-Authored-By: Claude Opus 4.5 <[email protected]> --- superset-frontend/src/dashboard/reducers/types.ts | 81 --------------- .../src/dashboard/util/propShapes.tsx | 114 --------------------- .../controls/FilterControl/adhocFilterType.test.ts | 104 ------------------- .../controls/FilterControl/adhocFilterType.ts | 52 ---------- .../components/controls/FilterControl/types.ts | 7 -- .../controls/MetricControl/adhocMetricType.ts | 35 ------- .../controls/MetricControl/savedMetricType.test.ts | 45 -------- .../controls/MetricControl/savedMetricType.ts | 19 ---- 8 files changed, 457 deletions(-) diff --git a/superset-frontend/src/dashboard/reducers/types.ts b/superset-frontend/src/dashboard/reducers/types.ts deleted file mode 100644 index 0656169b10e..00000000000 --- a/superset-frontend/src/dashboard/reducers/types.ts +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import componentTypes from 'src/dashboard/util/componentTypes'; - -export enum Scoping { - All = 'All', - Specific = 'Specific', -} - -export type User = { - email: string; - firstName: string; - isActive: boolean; - lastName: string; - permissions: Record<string, any>; - roles: Record<string, any>; - userId: number; - username: string; -}; -export interface DashboardInfo { - id: number; - json_metadata: string; -} - -/** Chart state of redux */ -export type Chart = { - id: number; - slice_id: string; - formData: { - viz_type: string; - }; -}; - -/** Root state of redux */ -export type RootState = { - charts: { [key: string]: Chart }; - dashboardLayout: { present: { [key: string]: LayoutItem } }; - dashboardFilters: {}; -}; - -/** State of dashboardLayout in redux */ -export type Layout = { [key: string]: LayoutItem }; - -/** State of charts in redux */ -export type Charts = { [key: number]: Chart }; - -type ComponentTypesKeys = keyof typeof componentTypes; -export type ComponentType = (typeof componentTypes)[ComponentTypesKeys]; - -/** State of dashboardLayout item in redux */ -export type LayoutItem = { - children: string[]; - parents: string[]; - type: ComponentType; - id: string; - meta: { - chartId: number; - height: number; - sliceName?: string; - text?: string; - uuid: string; - width: number; - }; -}; diff --git a/superset-frontend/src/dashboard/util/propShapes.tsx b/superset-frontend/src/dashboard/util/propShapes.tsx deleted file mode 100644 index 5ced7dd95c6..00000000000 --- a/superset-frontend/src/dashboard/util/propShapes.tsx +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import backgroundStyleOptions from './backgroundStyleOptions'; -import headerStyleOptions from './headerStyleOptions'; -import type { JsonObject } from '@superset-ui/core'; -import type { ComponentType } from '../types'; - -type HeaderSizeOption = (typeof headerStyleOptions)[number]['value']; -type BackgroundOption = (typeof backgroundStyleOptions)[number]['value']; - -// TypeScript interfaces - -export interface ComponentShape { - id: string; - type: ComponentType; - parents?: string[]; - children?: string[]; - meta?: { - width?: number; - height?: number; - headerSize?: HeaderSizeOption; - background?: BackgroundOption; - chartId?: number; - }; -} - -export interface ChartPropShape { - id: number; - chartAlert?: string; - chartStatus?: string; - chartUpdateEndTime?: number; - chartUpdateStartTime?: number; - latestQueryFormData?: JsonObject; - queryController?: { abort: () => void }; - queriesResponse?: JsonObject[]; - triggerQuery?: boolean; - lastRendered?: number; -} - -export interface SlicePropShape { - slice_id: number; - slice_url: string; - slice_name: string; - datasource?: string; - datasource_name?: string; - datasource_link?: string; - changed_on: number; - modified?: string; - viz_type: string; - description?: string; - description_markeddown?: string; - owners?: string[]; -} - -export interface DashboardFilterPropShape { - chartId: number; - componentId: string; - filterName: string; - datasourceId: string; - directPathToFilter: string[]; - isDateFilter: boolean; - isInstantFilter: boolean; - columns?: Record<string, unknown>; - labels?: Record<string, string>; - scopes?: Record<string, unknown>; -} - -export interface DashboardStatePropShape { - sliceIds?: number[]; - expandedSlices?: Record<string, boolean>; - editMode?: boolean; - isPublished?: boolean; - colorNamespace?: string; - colorScheme?: string; - updatedColorScheme?: boolean; - hasUnsavedChanges?: boolean; -} - -export interface DashboardInfoPropShape { - id?: number; - metadata?: JsonObject; - slug?: string; - dash_edit_perm?: boolean; - dash_save_perm?: boolean; - common?: JsonObject; - userId?: string; -} - -export interface FilterScopeLeafNode { - value: number | string; - label: string; -} - -export interface FilterScopeParentNode extends FilterScopeLeafNode { - children?: FilterScopeTreeNode[]; -} - -export type FilterScopeTreeNode = FilterScopeParentNode | FilterScopeLeafNode; diff --git a/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.test.ts b/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.test.ts deleted file mode 100644 index 27834620d18..00000000000 --- a/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.test.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { - AdhocFilterSimple, - AdhocFilterSql, - AdhocFilterType, -} from './adhocFilterType'; -import { Clauses, ExpressionTypes } from './types'; - -// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks -describe('adhocFilterType', () => { - test('should accept simple adhoc filter type', () => { - const simpleFilter: AdhocFilterSimple = { - expressionType: ExpressionTypes.Simple, - clause: Clauses.Where, - subject: 'column_name', - comparator: 'test_value', - }; - - expect(simpleFilter.expressionType).toBe(ExpressionTypes.Simple); - expect(simpleFilter.clause).toBe(Clauses.Where); - expect(simpleFilter.subject).toBe('column_name'); - expect(simpleFilter.comparator).toBe('test_value'); - }); - - test('should accept SQL adhoc filter type', () => { - const sqlFilter: AdhocFilterSql = { - expressionType: ExpressionTypes.Sql, - clause: Clauses.Having, - sqlExpression: 'COUNT(*) > 5', - }; - - expect(sqlFilter.expressionType).toBe(ExpressionTypes.Sql); - expect(sqlFilter.clause).toBe(Clauses.Having); - expect(sqlFilter.sqlExpression).toBe('COUNT(*) > 5'); - }); - - test('should accept both simple and SQL filters as AdhocFilterType', () => { - const simpleFilter: AdhocFilterType = { - expressionType: ExpressionTypes.Simple, - clause: Clauses.Where, - subject: 'column_name', - comparator: ['value1', 'value2'], - }; - - const sqlFilter: AdhocFilterType = { - expressionType: ExpressionTypes.Sql, - clause: Clauses.Having, - sqlExpression: 'AVG(sales) > 1000', - }; - - expect(simpleFilter.expressionType).toBe(ExpressionTypes.Simple); - expect(sqlFilter.expressionType).toBe(ExpressionTypes.Sql); - }); - - test('should handle array comparator for simple filters', () => { - const filterWithArrayComparator: AdhocFilterSimple = { - expressionType: ExpressionTypes.Simple, - clause: Clauses.Where, - subject: 'category', - comparator: ['A', 'B', 'C'], - }; - - expect(Array.isArray(filterWithArrayComparator.comparator)).toBe(true); - expect(filterWithArrayComparator.comparator).toEqual(['A', 'B', 'C']); - }); - - test('should handle optional properties', () => { - const filterWithOptionalProps: AdhocFilterSimple = { - expressionType: ExpressionTypes.Simple, - clause: Clauses.Where, - subject: 'column_name', - comparator: 'test_value', - operator: 'EQUALS', - operatorId: 'EQUALS', - isExtra: true, - isNew: false, - datasourceWarning: false, - deck_slices: [1, 2, 3], - layerFilterScope: 'global', - filterOptionName: 'custom_filter_name', - }; - - expect(filterWithOptionalProps.operator).toBe('EQUALS'); - expect(filterWithOptionalProps.isExtra).toBe(true); - expect(filterWithOptionalProps.deck_slices).toEqual([1, 2, 3]); - }); -}); diff --git a/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts b/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts deleted file mode 100644 index 0d32c7d7f0d..00000000000 --- a/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { Clauses, ExpressionTypes } from './types'; - -export interface AdhocFilterSimple { - expressionType: ExpressionTypes.Simple; - clause: Clauses.Having | Clauses.Where; - subject: string; - comparator: string | string[]; - operator?: string; - operatorId?: string; - isExtra?: boolean; - isNew?: boolean; - datasourceWarning?: boolean; - deck_slices?: number[]; - layerFilterScope?: string; - filterOptionName?: string; -} - -export interface AdhocFilterSql { - expressionType: ExpressionTypes.Sql; - clause: Clauses.Where | Clauses.Having; - sqlExpression: string; - subject?: string | null; - operator?: string | null; - operatorId?: string; - comparator?: null; - isExtra?: boolean; - isNew?: boolean; - datasourceWarning?: boolean; - deck_slices?: number[]; - layerFilterScope?: string; - filterOptionName?: string; -} - -export type AdhocFilterType = AdhocFilterSimple | AdhocFilterSql; diff --git a/superset-frontend/src/explore/components/controls/FilterControl/types.ts b/superset-frontend/src/explore/components/controls/FilterControl/types.ts index 869effd23a7..d2eebc5bffd 100644 --- a/superset-frontend/src/explore/components/controls/FilterControl/types.ts +++ b/superset-frontend/src/explore/components/controls/FilterControl/types.ts @@ -26,10 +26,3 @@ export enum Clauses { Having = 'HAVING', Where = 'WHERE', } - -// Re-export AdhocFilter types for convenient access -export type { - AdhocFilterSimple, - AdhocFilterSql, - AdhocFilterType, -} from './adhocFilterType'; diff --git a/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts b/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts deleted file mode 100644 index 6519f560f1a..00000000000 --- a/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { AGGREGATES } from 'src/explore/constants'; -import { EXPRESSION_TYPES } from './AdhocMetric'; - -export interface AdhocMetricSimple { - expressionType: typeof EXPRESSION_TYPES.SIMPLE; - column: { column_name: string; type?: string }; - aggregate: keyof typeof AGGREGATES; - label: string; -} - -export interface AdhocMetricSql { - expressionType: typeof EXPRESSION_TYPES.SQL; - sqlExpression: string; - label: string; -} - -export type AdhocMetricType = AdhocMetricSimple | AdhocMetricSql; diff --git a/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.test.ts b/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.test.ts deleted file mode 100644 index 91fc77f8036..00000000000 --- a/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { savedMetricType } from './savedMetricType'; - -test('savedMetricType exports the correct type structure', () => { - // Type assertion test - if this compiles without errors, - // the type structure is correct - const validMetric: savedMetricType = { - metric_name: 'test_metric', - verbose_name: 'Test Metric', - expression: 'SUM(column)', - }; - - expect(validMetric.metric_name).toBe('test_metric'); - expect(validMetric.verbose_name).toBe('Test Metric'); - expect(validMetric.expression).toBe('SUM(column)'); -}); - -test('savedMetricType allows optional verbose_name', () => { - // Test that verbose_name is optional - const validMetricMinimal: savedMetricType = { - metric_name: 'minimal_metric', - expression: 'COUNT(*)', - }; - - expect(validMetricMinimal.metric_name).toBe('minimal_metric'); - expect(validMetricMinimal.expression).toBe('COUNT(*)'); - expect(validMetricMinimal.verbose_name).toBeUndefined(); -}); diff --git a/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.ts b/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.ts deleted file mode 100644 index 2ebc81f0ab7..00000000000 --- a/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -export type { savedMetricType } from './types';
