You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/04/21 22:34:53 UTC
(superset) 01/01: chore(frontend): TypeScript 6.0 readiness — declaration emit fixes
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch ts6-migration/phase-a-readiness
in repository https://gitbox.apache.org/repos/asf/superset.git
commit f4ab36c5a80f33a4e1af3a8efda9252c75e33440
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Tue Apr 21 15:34:35 2026 -0700
chore(frontend): TypeScript 6.0 readiness — declaration emit fixes
Phase A of the TS 6.0 migration (see #39512). These are forward-compatible
changes that both compile cleanly on TS 5.4 today and prepare the codebase
for TS 6.0's stricter declaration-emit rules.
Changes by category:
- TS2883 (styled-component named references): Added `as typeof Component`
casts to styled() wrappers whose inferred return types reference
third-party types through nested node_modules paths that TS 6.0's
declaration emitter can't name.
* src/features/databases/DatabaseModal/styles.ts (StyledJsonEditor)
* src/features/reports/ReportModal/styles.tsx (StyledCronPicker)
- TS2882 (CSS side-effect imports): Added a module declaration for
`@fontsource/*` packages whose CSS files are imported for side effects.
* packages/superset-core/types/external.d.ts
- TS2564 (class property initialization): Added definite-assignment
assertions to class fields set via non-obvious initialization paths.
* packages/superset-core/src/theme/Theme.tsx
- TS4023/TS4082 (unexported type references in declaration emit): Added
`export` to interfaces and types referenced by exported symbols so TS
can emit proper .d.ts files. 15 files touched across dashboard/,
explore/, SqlLab/, dataMask/.
Verified:
- `tsc --build` completes cleanly on TS 5.4.5 with no regressions
- Full pre-commit suite passes on all 20 modified files
Context: Phase 0 diagnostic analysis showed TS 6.0 really only requires
~36 files of mechanical fixes, despite headline error counts suggesting
thousands. See the Phase 0 comment on #39512 for the breakdown.
Co-Authored-By: Claude Opus 4.7 <no...@anthropic.com>
---
superset-frontend/packages/superset-core/src/theme/Theme.tsx | 7 +++++--
superset-frontend/packages/superset-core/types/external.d.ts | 7 +++++++
superset-frontend/src/SqlLab/actions/sqlLab.ts | 8 ++++----
superset-frontend/src/dashboard/components/Dashboard.tsx | 2 +-
superset-frontend/src/dashboard/components/DashboardGrid.tsx | 2 +-
.../dashboard/components/filterscope/FilterScopeSelector.tsx | 2 +-
.../components/gridComponents/ChartHolder/ChartHolder.tsx | 2 +-
.../src/dashboard/components/gridComponents/Column/Column.tsx | 2 +-
.../dashboard/components/gridComponents/Markdown/Markdown.tsx | 10 +++++-----
.../src/dashboard/components/gridComponents/Tab/Tab.tsx | 2 +-
.../src/dashboard/components/gridComponents/Tabs/Tabs.tsx | 2 +-
superset-frontend/src/dashboard/reducers/dashboardFilters.ts | 2 +-
superset-frontend/src/dashboard/reducers/dashboardInfo.ts | 2 +-
superset-frontend/src/dataMask/reducer.ts | 2 +-
.../explore/components/controls/CollectionControl/index.tsx | 2 +-
.../explore/components/controls/DatasourceControl/index.tsx | 2 +-
.../controls/FilterControl/AdhocFilterControl/index.tsx | 2 +-
.../components/controls/MetricControl/MetricsControl.tsx | 2 +-
.../src/features/databases/DatabaseModal/styles.ts | 9 ++++++++-
superset-frontend/src/features/reports/ReportModal/styles.tsx | 5 ++++-
20 files changed, 47 insertions(+), 27 deletions(-)
diff --git a/superset-frontend/packages/superset-core/src/theme/Theme.tsx b/superset-frontend/packages/superset-core/src/theme/Theme.tsx
index 138a0ace9b6..a0c02f740d0 100644
--- a/superset-frontend/packages/superset-core/src/theme/Theme.tsx
+++ b/superset-frontend/packages/superset-core/src/theme/Theme.tsx
@@ -38,9 +38,12 @@ import {
import { normalizeThemeConfig, serializeThemeConfig } from './utils';
export class Theme {
- theme: SupersetTheme;
+ // Assigned via setConfig() in the constructor; TypeScript 6.0's
+ // strictPropertyInitialization can't trace that call chain, so we use
+ // a definite-assignment assertion.
+ theme!: SupersetTheme;
- private antdConfig: AntdThemeConfig;
+ private antdConfig!: AntdThemeConfig;
private constructor({ config }: { config?: AnyThemeConfig }) {
this.SupersetThemeProvider = this.SupersetThemeProvider.bind(this);
diff --git a/superset-frontend/packages/superset-core/types/external.d.ts b/superset-frontend/packages/superset-core/types/external.d.ts
index dcce5fa8823..da31a12abc8 100644
--- a/superset-frontend/packages/superset-core/types/external.d.ts
+++ b/superset-frontend/packages/superset-core/types/external.d.ts
@@ -20,3 +20,10 @@
* Stub for the untyped jed module.
*/
declare module 'jed';
+
+/**
+ * CSS side-effect imports from @fontsource packages. These are bundler-only
+ * artifacts and carry no type information at runtime; declaring them here
+ * silences TS2882 under TypeScript 6.0's stricter module-resolution rules.
+ */
+declare module '@fontsource/*';
diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.ts b/superset-frontend/src/SqlLab/actions/sqlLab.ts
index dc5441ecfd0..883f50d40f1 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.ts
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.ts
@@ -856,7 +856,7 @@ export function loadQueryEditor(queryEditor: QueryEditor): SqlLabAction {
return { type: LOAD_QUERY_EDITOR, queryEditor };
}
-interface TableSchema {
+export interface TableSchema {
description: {
columns: unknown[];
selectStar: string;
@@ -1284,7 +1284,7 @@ export function addTable(
};
}
-interface NewTable {
+export interface NewTable {
id?: string;
dbId: number | string;
catalog?: string | null;
@@ -1346,7 +1346,7 @@ export function runTablePreviewQuery(
};
}
-interface TableMetaData {
+export interface TableMetaData {
columns?: unknown[];
selectStar?: string;
primaryKey?: unknown;
@@ -1660,7 +1660,7 @@ export function createDatasourceFailed(err: string): SqlLabAction {
return { type: CREATE_DATASOURCE_FAILED, err };
}
-interface VizOptions {
+export interface VizOptions {
dbId: number;
catalog?: string | null;
schema: string;
diff --git a/superset-frontend/src/dashboard/components/Dashboard.tsx b/superset-frontend/src/dashboard/components/Dashboard.tsx
index d349a89464c..51519ba2309 100644
--- a/superset-frontend/src/dashboard/components/Dashboard.tsx
+++ b/superset-frontend/src/dashboard/components/Dashboard.tsx
@@ -67,7 +67,7 @@ interface DashboardActions {
setDatasources: (datasources: unknown) => void;
}
-interface DashboardProps {
+export interface DashboardProps {
actions: DashboardActions;
dashboardId: number;
editMode?: boolean;
diff --git a/superset-frontend/src/dashboard/components/DashboardGrid.tsx b/superset-frontend/src/dashboard/components/DashboardGrid.tsx
index 9fdefeb5cbf..bd726202a47 100644
--- a/superset-frontend/src/dashboard/components/DashboardGrid.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardGrid.tsx
@@ -32,7 +32,7 @@ import { Droppable } from './dnd/DragDroppable';
import { GRID_GUTTER_SIZE, GRID_COLUMN_COUNT } from '../util/constants';
import { TAB_TYPE } from '../util/componentTypes';
-interface DashboardGridProps {
+export interface DashboardGridProps {
depth: number;
editMode?: boolean;
canEdit?: boolean;
diff --git a/superset-frontend/src/dashboard/components/filterscope/FilterScopeSelector.tsx b/superset-frontend/src/dashboard/components/filterscope/FilterScopeSelector.tsx
index 7d10c1b691d..63e585d852f 100644
--- a/superset-frontend/src/dashboard/components/filterscope/FilterScopeSelector.tsx
+++ b/superset-frontend/src/dashboard/components/filterscope/FilterScopeSelector.tsx
@@ -80,7 +80,7 @@ interface FilterScopeMap {
[key: string]: FilterScopeMapEntry;
}
-interface FilterScopeSelectorProps {
+export interface FilterScopeSelectorProps {
dashboardFilters: Record<number, DashboardFilter>;
layout: DashboardLayout;
updateDashboardFiltersScope: (
diff --git a/superset-frontend/src/dashboard/components/gridComponents/ChartHolder/ChartHolder.tsx b/superset-frontend/src/dashboard/components/gridComponents/ChartHolder/ChartHolder.tsx
index 7f2658a9667..2616f6eb434 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/ChartHolder/ChartHolder.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/ChartHolder/ChartHolder.tsx
@@ -42,7 +42,7 @@ import {
export const CHART_MARGIN = 32;
-interface ChartHolderProps {
+export interface ChartHolderProps {
id: string;
parentId: string;
dashboardId: number;
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Column/Column.tsx b/superset-frontend/src/dashboard/components/gridComponents/Column/Column.tsx
index 4f8baf16a69..e3a9de04cef 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Column/Column.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Column/Column.tsx
@@ -39,7 +39,7 @@ import backgroundStyleOptions from 'src/dashboard/util/backgroundStyleOptions';
import { BACKGROUND_TRANSPARENT } from 'src/dashboard/util/constants';
import { EMPTY_CONTAINER_Z_INDEX } from 'src/dashboard/constants';
-interface ColumnProps {
+export interface ColumnProps {
id: string;
parentId: string;
component: LayoutItem;
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Markdown/Markdown.tsx b/superset-frontend/src/dashboard/components/gridComponents/Markdown/Markdown.tsx
index b10e4e23224..55f7426348d 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Markdown/Markdown.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Markdown/Markdown.tsx
@@ -43,13 +43,13 @@ import {
GRID_BASE_UNIT,
} from 'src/dashboard/util/constants';
-interface EditorInstance {
+export interface EditorInstance {
resize?: (force: boolean) => void;
getSession?: () => { setUseWrapMode: (wrap: boolean) => void };
focus?: () => void;
}
-interface MarkdownOwnProps {
+export interface MarkdownOwnProps {
id: string;
parentId: string;
component: LayoutItem;
@@ -71,7 +71,7 @@ interface MarkdownOwnProps {
updateComponents: (components: Record<string, LayoutItem>) => void;
}
-interface MarkdownStateProps {
+export interface MarkdownStateProps {
logEvent: (eventName: string, eventData: JsonObject) => void;
addDangerToast: (msg: string) => void;
undoLength: number;
@@ -80,9 +80,9 @@ interface MarkdownStateProps {
htmlSchemaOverrides?: JsonObject;
}
-type MarkdownProps = MarkdownOwnProps & MarkdownStateProps;
+export type MarkdownProps = MarkdownOwnProps & MarkdownStateProps;
-interface MarkdownState {
+export interface MarkdownState {
isFocused: boolean;
markdownSource: string;
editor: EditorInstance | null;
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Tab/Tab.tsx b/superset-frontend/src/dashboard/components/gridComponents/Tab/Tab.tsx
index 86ef757b4a7..f2486a80dc8 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Tab/Tab.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Tab/Tab.tsx
@@ -57,7 +57,7 @@ export const RENDER_TAB_CONTENT = 'RENDER_TAB_CONTENT';
// Delay before refreshing charts to ensure they are fully mounted
const CHART_MOUNT_DELAY = 100;
-interface TabProps {
+export interface TabProps {
dashboardId: number;
id: string;
parentId: string;
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Tabs/Tabs.tsx b/superset-frontend/src/dashboard/components/gridComponents/Tabs/Tabs.tsx
index d3eacb0cf7d..26c9b79d603 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Tabs/Tabs.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Tabs/Tabs.tsx
@@ -44,7 +44,7 @@ import TabsRenderer from '../TabsRenderer';
import type { LayoutItem, RootState } from 'src/dashboard/types';
import type { DropResult } from 'src/dashboard/components/dnd/dragDroppableConfig';
-interface TabsProps {
+export interface TabsProps {
id: string;
parentId: string;
component: LayoutItem;
diff --git a/superset-frontend/src/dashboard/reducers/dashboardFilters.ts b/superset-frontend/src/dashboard/reducers/dashboardFilters.ts
index d4defa36c72..062673bb8b5 100644
--- a/superset-frontend/src/dashboard/reducers/dashboardFilters.ts
+++ b/superset-frontend/src/dashboard/reducers/dashboardFilters.ts
@@ -30,7 +30,7 @@ import { buildActiveFilters } from '../util/activeDashboardFilters';
import { getChartIdAndColumnFromFilterKey } from '../util/getDashboardFilterKey';
import { LayoutItem } from '../types';
-interface FilterScope {
+export interface FilterScope {
scope: string[];
immune: number[];
}
diff --git a/superset-frontend/src/dashboard/reducers/dashboardInfo.ts b/superset-frontend/src/dashboard/reducers/dashboardInfo.ts
index 94a1f671058..68722eaedc6 100644
--- a/superset-frontend/src/dashboard/reducers/dashboardInfo.ts
+++ b/superset-frontend/src/dashboard/reducers/dashboardInfo.ts
@@ -57,7 +57,7 @@ interface DashboardInfoAction {
[key: string]: unknown;
}
-interface HydrateDashboardAction {
+export interface HydrateDashboardAction {
type: typeof HYDRATE_DASHBOARD;
data: {
dashboardInfo: DashboardInfo;
diff --git a/superset-frontend/src/dataMask/reducer.ts b/superset-frontend/src/dataMask/reducer.ts
index 5ae614eb048..1d12ebe03b2 100644
--- a/superset-frontend/src/dataMask/reducer.ts
+++ b/superset-frontend/src/dataMask/reducer.ts
@@ -66,7 +66,7 @@ interface DashboardMetadata {
chart_customization_config?: ChartCustomization[];
}
-interface HydrateDashboardAction {
+export interface HydrateDashboardAction {
type: typeof HYDRATE_DASHBOARD;
data: {
dashboardInfo: {
diff --git a/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx b/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
index d21ffeecc69..b44a90bc182 100644
--- a/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
@@ -41,7 +41,7 @@ interface CollectionItem {
[key: string]: unknown;
}
-interface CollectionControlProps {
+export interface CollectionControlProps {
name: string;
label?: string | null;
description?: string | null;
diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx b/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx
index 76136b8b483..8c6cd202215 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx
@@ -91,7 +91,7 @@ interface FormData {
[key: string]: unknown;
}
-interface DatasourceControlProps {
+export interface DatasourceControlProps {
actions: DatasourceControlActions;
onChange?: () => void;
value?: string | null;
diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.tsx
index f51da2fdc13..943d9100846 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.tsx
@@ -69,7 +69,7 @@ interface Datasource {
[key: string]: unknown;
}
-interface AdhocFilterControlProps {
+export interface AdhocFilterControlProps {
label?: ReactNode;
name?: string;
sections?: string[];
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx b/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx
index a3cd9bad883..656d01bb310 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx
@@ -108,7 +108,7 @@ const getMetricsMatchingCurrentDataset = (
);
});
-interface MetricsControlProps {
+export interface MetricsControlProps {
name: string;
onChange: (value: unknown) => void;
multi?: boolean;
diff --git a/superset-frontend/src/features/databases/DatabaseModal/styles.ts b/superset-frontend/src/features/databases/DatabaseModal/styles.ts
index c8e37d93412..8aa9aa16ec2 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/styles.ts
+++ b/superset-frontend/src/features/databases/DatabaseModal/styles.ts
@@ -293,10 +293,17 @@ export const StyledInputContainer = styled.div`
`}
`;
+// Named-reference type annotation: TypeScript 6.0 declaration emit (TS2883)
+// won't let us leak react-ace's IAceOptions/ICommand/IEditorProps/IMarker
+// through the inferred type because they live in @superset-ui/core's nested
+// node_modules and aren't portable. Aliasing to `typeof JsonEditor` emits a
+// named reference in the .d.ts instead of the expanded structural type.
+// The styled-components and ForwardRefExoticComponent shapes don't overlap
+// structurally, so we bounce through `unknown` to widen the cast.
export const StyledJsonEditor = styled(JsonEditor)`
flex: 1 1 auto;
/* Border is already applied by AceEditor itself */
-`;
+` as unknown as typeof JsonEditor;
export const StyledExpandableForm = styled.div`
padding-top: ${({ theme }) => theme.sizeUnit}px;
diff --git a/superset-frontend/src/features/reports/ReportModal/styles.tsx b/superset-frontend/src/features/reports/ReportModal/styles.tsx
index 14acc3e0012..0b487bd6803 100644
--- a/superset-frontend/src/features/reports/ReportModal/styles.tsx
+++ b/superset-frontend/src/features/reports/ReportModal/styles.tsx
@@ -67,10 +67,13 @@ export const StyledScheduleTitle = styled.div`
}
`;
+// Named-reference type annotation: TypeScript 6.0 declaration emit (TS2883)
+// can't name CronProps from react-js-cron via its nested node_modules path.
+// Aliasing to `typeof CronPicker` emits a named reference in the .d.ts.
export const StyledCronPicker = styled(CronPicker)`
margin-bottom: ${({ theme }) => theme.sizeUnit * 3}px;
width: ${({ theme }) => theme.sizeUnit * 120}px;
-`;
+` as typeof CronPicker;
export const StyledCronError = styled.p`
color: ${({ theme }) => theme.colorError};