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/02/03 06:35:41 UTC
(superset) 05/08: chore(frontend): TypeScript quality improvements across phases 1-5
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 273fc93752dd4753b2916f74967f82fdd4014558
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Tue Feb 3 04:43:05 2026 +0100
chore(frontend): TypeScript quality improvements across phases 1-5
Improve type safety and modernize TypeScript patterns across the frontend:
- Phase 1a: Add proper ThunkAction/ThunkDispatch typing to SqlLab actions
- Phase 1b: Add explicit return types and type annotations to dashboard actions
- Phase 2: Remove legacy PropTypes from TypeScript files (use TS interfaces)
- Phase 4: Migrate @ts-ignore to @ts-expect-error with explanatory comments
- Phase 5: Remove legacy .swcrc and clean up webpack configuration
- Fix all type errors introduced by agent migrations (0 tsc errors)
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
superset-frontend/.swcrc | 64 ----
superset-frontend/package.json | 1 -
.../superset-core/src/ui/theme/utils/utils.test.ts | 8 +-
.../operators/utils/extractExtraMetrics.test.ts | 2 +-
.../test/utils/defineSavedMetrics.test.tsx | 2 +-
.../test/utils/getColorFormatters.test.ts | 2 +-
.../src/components/AsyncEsmComponent/index.tsx | 2 +-
.../components/CronPicker/CronPicker.stories.tsx | 2 +-
.../src/components/Dropdown/Dropdown.test.tsx | 2 +-
.../src/components/Label/Label.test.tsx | 2 +-
.../src/components/Select/AsyncSelect.tsx | 6 +-
.../src/components/Select/Select.tsx | 2 +-
.../src/components/Table/sorters.test.ts | 26 +-
.../src/components/Table/utils/utils.test.ts | 8 +-
.../TableCollection/TableCollection.test.tsx | 2 +-
.../src/components/TelemetryPixel/index.tsx | 2 +-
.../TimezoneSelector/TimezoneOptionsCache.test.tsx | 2 +-
.../superset-ui-core/src/math-expression/index.ts | 2 +-
.../src/models/ExtensibleFunction.ts | 2 +-
.../superset-ui-core/src/query/normalizeOrderBy.ts | 2 +-
.../src/query/processExtraFormData.ts | 2 +-
.../test/chart/components/SuperChartCore.test.tsx | 2 +-
.../test/chart/components/reactify.test.tsx | 2 +-
.../test/connection/SupersetClientClass.test.ts | 10 +-
.../test/currency-format/CurrencyFormatter.test.ts | 10 +-
.../test/dimension/getBBoxDummyFill.ts | 6 +-
.../test/dimension/mergeMargin.test.ts | 2 +-
.../test/models/ExtensibleFunction.test.ts | 4 +-
.../test/number-format/NumberFormatter.test.ts | 4 +-
.../number-format/NumberFormatterRegistry.test.ts | 2 +-
.../factories/createD3NumberFormatter.test.ts | 2 +-
.../test/query/api/v1/makeApi.test.ts | 2 +-
.../test/query/getClientErrorObject.test.ts | 8 +-
.../test/query/normalizeOrderBy.test.ts | 2 +-
.../test/time-format/TimeFormatter.test.ts | 4 +-
.../test/time-format/TimeFormatterRegistry.test.ts | 2 +-
.../factories/createD3TimeFormatter.test.ts | 4 +-
.../test/utils/getSelectedText.test.ts | 2 +-
.../stories/plugins/plugin-chart-table/testData.ts | 2 +-
.../legacy-preset-chart-deckgl/src/Multi/Multi.tsx | 2 +-
.../src/layers/Grid/Grid.tsx | 6 +-
.../src/layers/Hex/Hex.tsx | 6 +-
.../src/utils/formatValue.ts | 2 +-
.../src/util/layerUtil.tsx | 1 -
.../test/util/layerUtil.test.ts | 4 +-
.../src/BigNumber/BigNumberViz.tsx | 2 +-
.../BigNumberWithTrendline/transformProps.ts | 4 +-
.../src/BoxPlot/transformProps.ts | 4 +-
.../plugin-chart-echarts/src/BoxPlot/types.ts | 2 +-
.../src/Funnel/transformProps.ts | 2 +-
.../plugin-chart-echarts/src/Funnel/types.ts | 2 +-
.../src/Gauge/transformProps.ts | 2 +-
.../plugin-chart-echarts/src/Graph/types.ts | 2 +-
.../src/MixedTimeseries/EchartsMixedTimeseries.tsx | 1 -
.../src/MixedTimeseries/index.ts | 2 +-
.../src/MixedTimeseries/transformProps.ts | 2 +-
.../src/MixedTimeseries/types.ts | 2 +-
.../plugins/plugin-chart-echarts/src/Pie/types.ts | 2 +-
.../plugin-chart-echarts/src/Radar/types.ts | 2 +-
.../src/Timeseries/EchartsTimeseries.tsx | 2 +-
.../src/Timeseries/constants.ts | 2 +-
.../src/Timeseries/transformers.ts | 10 +-
.../test/BigNumber/transformProps.test.ts | 6 +-
.../test/Timeseries/Scatter/controlPanel.test.ts | 2 +-
.../test/Timeseries/Scatter/transformProps.test.ts | 4 -
.../test/sortAlphanumericCaseInsensitive.test.ts | 2 +-
superset-frontend/spec/helpers/ProviderWrapper.tsx | 8 +-
superset-frontend/spec/helpers/testing-library.tsx | 7 +-
.../src/SqlLab/actions/sqlLab.test.ts | 51 +--
superset-frontend/src/SqlLab/actions/sqlLab.ts | 353 ++++++++++-----------
.../components/EditorWrapper/useKeywords.test.ts | 8 +-
.../QueryAutoRefresh/QueryAutoRefresh.test.tsx | 23 +-
.../SqlLab/components/ResultSet/ResultSet.test.tsx | 1 -
.../SaveDatasetModal/SaveDatasetModal.test.tsx | 6 +-
.../src/SqlLab/components/SqlEditor/index.tsx | 7 +-
.../src/SqlLab/reducers/getInitialState.ts | 2 +
.../TimeColumn/TimeColumnFilterPlugin.tsx | 2 +-
.../Chart/ChartContextMenu/useContextMenu.test.tsx | 2 +-
.../ErrorMessage/DatabaseErrorMessage.test.tsx | 2 +-
.../ErrorMessage/ErrorMessageWithStackTrace.tsx | 2 +-
.../src/components/ListView/ListView.test.tsx | 13 +-
.../src/dashboard/actions/dashboardLayout.ts | 52 ++-
.../src/dashboard/actions/dashboardState.ts | 131 ++++----
superset-frontend/src/dashboard/actions/hydrate.ts | 44 +--
.../DashboardBuilder/DashboardBuilder.tsx | 2 -
.../src/dashboard/components/SliceAdder.tsx | 2 +-
.../components/SliceHeader/SliceHeader.test.tsx | 32 --
.../SliceHeaderControls.test.tsx | 15 +-
.../DynamicComponent/DynamicComponent.tsx | 2 -
.../menu/ShareMenuItems/ShareMenuItems.test.tsx | 3 +-
.../components/nativeFilters/FilterBar/state.ts | 2 +-
.../nativeFilters/FilterCard/FilterCard.test.tsx | 1 -
.../FiltersConfigForm/FiltersConfigForm.tsx | 12 +-
.../FiltersConfigForm/getControlItemsMap.test.tsx | 5 +-
.../FiltersConfigModal/NativeFiltersModal.test.tsx | 1 -
.../dashboard/components/nativeFilters/utils.ts | 2 +-
.../components/resizable/ResizableContainer.tsx | 4 +-
.../src/dashboard/util/crossFilters.test.ts | 3 +-
.../src/dashboard/util/extractUrlParams.test.ts | 4 +-
.../src/dashboard/util/findParentId.test.ts | 8 +-
.../src/dashboard/util/propShapes.tsx | 94 ------
.../src/embedded/EmbeddedContextProviders.tsx | 7 +-
.../src/explore/actions/datasourcesActions.test.ts | 2 +-
.../src/explore/actions/hydrateExplore.test.ts | 12 +-
.../CopyToClipboardButton.test.tsx | 4 +-
.../DataTablesPane/test/DataTablesPane.test.tsx | 2 +-
.../explore/components/DatasourcePanel/index.tsx | 2 +-
.../controls/CollectionControl/index.tsx | 18 --
.../ControlForm/ControlFormItem.tsx | 2 +-
.../DatasourceControl/DatasourceControl.test.tsx | 9 +-
.../controls/DatasourceControl/index.tsx | 22 --
.../DndColumnSelectControl/ColumnSelectPopover.tsx | 2 +-
.../FilterControl/AdhocFilterControl/index.tsx | 33 +-
.../FilterControl/AdhocFilterEditPopover/index.tsx | 26 --
.../AdhocFilterEditPopoverSqlTabContent/index.tsx | 2 +-
.../controls/FilterControl/adhocFilterType.ts | 12 -
.../controls/FilterControl/utils/translateToSQL.ts | 7 +-
.../controls/FixedOrMetricControl/index.tsx | 16 +-
.../MetricControl/AdhocMetricEditPopover/index.tsx | 22 +-
.../controls/MetricControl/AdhocMetricOption.tsx | 22 --
.../MetricControl/FilterDefinitionOption.tsx | 13 -
.../MetricControl/MetricDefinitionValue.tsx | 19 --
.../controls/MetricControl/MetricsControl.tsx | 20 --
.../controls/MetricControl/adhocMetricType.ts | 30 +-
.../controls/MetricControl/savedMetricType.ts | 12 -
.../explore/components/controls/SelectControl.tsx | 52 ---
.../components/controls/TextAreaControl.tsx | 37 ---
.../controls/TimeSeriesColumnControl/index.tsx | 21 --
.../ZoomConfigControl/ZoomConfigControl.tsx | 8 +-
.../controls/ZoomConfigControl/zoomUtil.test.ts | 2 +-
.../exploreUtils/getParsedExploreURLParams.test.ts | 2 +-
.../src/extensions/ExtensionsManager.ts | 4 +-
.../src/features/alerts/AlertReportModal.test.tsx | 2 +-
.../src/features/alerts/AlertReportModal.tsx | 2 -
.../DatabaseModal/DatabaseConnectionForm/index.tsx | 3 +-
.../src/features/tags/BulkTagModal.tsx | 4 +-
superset-frontend/src/features/tags/TagModal.tsx | 6 +-
.../components/Range/RangeFilterPlugin.test.tsx | 8 +-
.../filters/components/Range/RangeFilterPlugin.tsx | 2 +-
.../src/filters/components/Range/buildQuery.ts | 2 +-
.../components/Select/SelectFilterPlugin.test.tsx | 48 +--
.../components/Select/SelectFilterPlugin.tsx | 2 +-
.../TimeColumn/TimeColumnFilterPlugin.tsx | 2 +-
.../components/TimeGrain/TimeGrainFilterPlugin.tsx | 2 +-
superset-frontend/src/filters/utils.ts | 1 -
.../pages/AlertReportList/AlertReportList.test.tsx | 3 +-
.../AnnotationLayerList.test.tsx | 3 +-
.../pages/ChartList/ChartList.permissions.test.tsx | 3 +-
.../src/pages/ChartList/ChartList.testHelpers.tsx | 3 +-
.../pages/CssTemplateList/CssTemplateList.test.tsx | 3 +-
.../src/pages/DashboardList/DashboardList.test.tsx | 5 +-
.../src/pages/GroupsList/GroupsList.test.tsx | 3 +-
superset-frontend/src/pages/Home/Home.test.tsx | 6 +-
.../src/pages/RolesList/RolesList.test.tsx | 3 +-
.../RowLevelSecurityList.test.tsx | 3 +-
.../pages/SavedQueryList/SavedQueryList.test.tsx | 3 +-
.../src/pages/UserInfo/UserInfo.test.tsx | 3 +-
.../src/pages/UsersList/UsersList.test.tsx | 3 +-
superset-frontend/src/setup/setupColors.ts | 2 -
superset-frontend/src/views/CRUD/utils.tsx | 1 -
.../src/views/RootContextProviders.tsx | 7 +-
superset-frontend/src/views/menu.tsx | 9 +-
superset-frontend/tsconfig.json | 1 +
superset-frontend/webpack.config.js | 15 +-
164 files changed, 592 insertions(+), 1212 deletions(-)
diff --git a/superset-frontend/.swcrc b/superset-frontend/.swcrc
deleted file mode 100644
index fc5a4336695..00000000000
--- a/superset-frontend/.swcrc
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/swcrc",
- "jsc": {
- "parser": {
- "syntax": "typescript",
- "tsx": true,
- "decorators": false,
- "dynamicImport": true
- },
- "transform": {
- "react": {
- "runtime": "automatic",
- "importSource": "@emotion/react",
- "throwIfNamespace": true
- },
- "optimizer": {
- "globals": {
- "vars": {
- "process.env.NODE_ENV": "production"
- }
- }
- }
- },
- "target": "es2015",
- "loose": true,
- "externalHelpers": false,
- "preserveAllComments": false,
- "experimental": {
- "plugins": [
- [
- "@swc/plugin-emotion",
- {
- "sourceMap": true,
- "autoLabel": "dev-only",
- "labelFormat": "[local]"
- }
- ],
- [
- "@swc/plugin-transform-imports",
- {
- "lodash": {
- "transform": "lodash/{{member}}",
- "preventFullImport": true,
- "skipDefaultConversion": false
- },
- "lodash-es": {
- "transform": "lodash-es/{{member}}",
- "preventFullImport": true,
- "skipDefaultConversion": false
- }
- }
- ]
- ]
- }
- },
- "module": {
- "type": "es6",
- "strict": false,
- "strictMode": false,
- "lazy": false,
- "noInterop": false
- },
- "minify": false
-}
diff --git a/superset-frontend/package.json b/superset-frontend/package.json
index d5262b39797..c651fccdfb9 100644
--- a/superset-frontend/package.json
+++ b/superset-frontend/package.json
@@ -356,7 +356,6 @@
"terser-webpack-plugin": "^5.3.16",
"thread-loader": "^4.0.4",
"ts-jest": "^29.4.6",
- "ts-loader": "^9.5.4",
"tscw-config": "^1.1.2",
"tsx": "^4.21.0",
"typescript": "5.4.5",
diff --git a/superset-frontend/packages/superset-core/src/ui/theme/utils/utils.test.ts b/superset-frontend/packages/superset-core/src/ui/theme/utils/utils.test.ts
index 20603d81a1d..c1a45d73388 100644
--- a/superset-frontend/packages/superset-core/src/ui/theme/utils/utils.test.ts
+++ b/superset-frontend/packages/superset-core/src/ui/theme/utils/utils.test.ts
@@ -202,7 +202,7 @@ test('serializeThemeConfig defaults to "default" for unknown algorithms', () =>
const unknownAlgorithm = () => ({});
const config: AntdThemeConfig = {
token: { colorPrimary: '#ff0000' },
- // @ts-ignore
+ // @ts-expect-error
algorithm: unknownAlgorithm,
};
@@ -237,7 +237,7 @@ test('serializeThemeConfig defaults each unknown algorithm in array to "default"
const unknownAlgorithm = () => ({});
const config: AntdThemeConfig = {
token: { colorPrimary: '#ff0000' },
- // @ts-ignore
+ // @ts-expect-error
algorithm: [antdThemeImport.darkAlgorithm, unknownAlgorithm],
};
@@ -257,10 +257,10 @@ test('serializeThemeConfig handles mixed known and unknown algorithms in array',
token: { colorPrimary: '#ff0000' },
algorithm: [
antdThemeImport.darkAlgorithm,
- // @ts-ignore
+ // @ts-expect-error
unknownAlgorithm1,
antdThemeImport.compactAlgorithm,
- // @ts-ignore
+ // @ts-expect-error
unknownAlgorithm2,
],
};
diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/operators/utils/extractExtraMetrics.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/operators/utils/extractExtraMetrics.test.ts
index 116bfa7fd9a..dd2a10cbe55 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/test/operators/utils/extractExtraMetrics.test.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/test/operators/utils/extractExtraMetrics.test.ts
@@ -129,7 +129,7 @@ test('returns empty array if timeseries_limit_metric is an empty array', () => {
expect(
extractExtraMetrics({
...baseFormData,
- // @ts-ignore
+ // @ts-expect-error
timeseries_limit_metric: [],
}),
).toEqual([]);
diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/utils/defineSavedMetrics.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/utils/defineSavedMetrics.test.tsx
index f1c64ad4a71..a32a49028da 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/test/utils/defineSavedMetrics.test.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/test/utils/defineSavedMetrics.test.tsx
@@ -51,7 +51,7 @@ describe('defineSavedMetrics', () => {
uuid: '1',
},
]);
- // @ts-ignore
+ // @ts-expect-error
expect(defineSavedMetrics({ ...dataset, metrics: undefined })).toEqual([]);
});
diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts
index 68a06e2d15a..e1be6ae36e3 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/test/utils/getColorFormatters.test.ts
@@ -306,7 +306,7 @@ test('getColorFunction BETWEEN with target value right undefined', () => {
test('getColorFunction unsupported operator', () => {
const colorFunction = getColorFunction(
{
- // @ts-ignore
+ // @ts-expect-error
operator: 'unsupported operator',
targetValue: 50,
colorScheme: '#FF0000',
diff --git a/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx
index dd643a8e1a6..5f8562cd3eb 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx
@@ -119,7 +119,7 @@ export function AsyncEsmComponent<
const Component = component || placeholder;
return Component ? (
// placeholder does not get the ref
- // @ts-ignore: Suppress TypeScript error for ref assignment
+ // @ts-expect-error: Suppress TypeScript error for ref assignment
<Component ref={Component === component ? ref : null} {...props} />
) : null;
});
diff --git a/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.stories.tsx
index 1bc2748f939..63276a99e2e 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.stories.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.stories.tsx
@@ -28,7 +28,7 @@ export default {
};
export const InteractiveCronPicker = (props: CronProps) => {
- // @ts-ignore
+ // @ts-expect-error
const inputRef = useRef<Input>(null);
const [value, setValue] = useState(props.value);
const customSetValue = useCallback(
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx
index 9baaef9adbf..02ef9440581 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx
@@ -26,7 +26,7 @@ const props = {
describe('NoAnimationDropdown', () => {
it('requires children', () => {
expect(() => {
- // @ts-ignore need to test the error case
+ // @ts-expect-error need to test the error case
render(<NoAnimationDropdown {...props} />);
}).toThrow();
});
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Label/Label.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Label/Label.test.tsx
index 1dff7c6e697..9d5dc184d31 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Label/Label.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Label/Label.test.tsx
@@ -36,7 +36,7 @@ test('works with an onClick handler', () => {
// test stories from the storybook!
test('renders all the storybook gallery variants', () => {
- // @ts-ignore: Suppress TypeScript error for LabelGallery usage
+ // @ts-expect-error: Suppress TypeScript error for LabelGallery usage
const { container } = render(<LabelGallery />);
const nonInteractiveLabelCount = 4;
const renderedLabelCount = options.length * 2 + nonInteractiveLabelCount;
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
index bfa2e801a30..172632da03d 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
@@ -479,10 +479,10 @@ const AsyncSelect = forwardRef(
fullSelectOptions.filter(opt => set.has(opt.value)),
);
if (isSingleMode) {
- // @ts-ignore
+ // @ts-expect-error
onChange?.(selectValue, options[0]);
} else {
- // @ts-ignore
+ // @ts-expect-error
onChange?.(array, options);
}
}
@@ -619,7 +619,7 @@ const AsyncSelect = forwardRef(
onBlur={handleOnBlur}
onDeselect={handleOnDeselect}
onOpenChange={handleOnDropdownVisibleChange}
- // @ts-ignore
+ // @ts-expect-error
onPaste={onPaste}
onPopupScroll={handlePagination}
onSearch={showSearch ? handleOnSearch : undefined}
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
index 222ba643bcd..569f865333c 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
@@ -748,7 +748,7 @@ const Select = forwardRef(
onBlur={handleOnBlur}
onDeselect={handleOnDeselect}
onOpenChange={handleOnDropdownVisibleChange}
- // @ts-ignore
+ // @ts-expect-error
onPaste={onPaste}
onPopupScroll={undefined}
onSearch={shouldShowSearch ? handleOnSearch : undefined}
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Table/sorters.test.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/sorters.test.ts
index d4f506ac3ed..8e6a4393dc2 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Table/sorters.test.ts
+++ b/superset-frontend/packages/superset-ui-core/src/components/Table/sorters.test.ts
@@ -45,20 +45,20 @@ const rows = [
* 1 or greater means the first item comes before the second item
*/
test('alphabeticalSort sorts correctly', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(alphabeticalSort('name', rows[0], rows[1])).toBe(-1);
- // @ts-ignore
+ // @ts-expect-error
expect(alphabeticalSort('name', rows[1], rows[0])).toBe(1);
- // @ts-ignore
+ // @ts-expect-error
expect(alphabeticalSort('category', rows[1], rows[0])).toBe(0);
});
test('numericalSort sorts correctly', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(numericalSort('cost', rows[1], rows[2])).toBe(0);
- // @ts-ignore
+ // @ts-expect-error
expect(numericalSort('cost', rows[1], rows[0])).toBeLessThan(0);
- // @ts-ignore
+ // @ts-expect-error
expect(numericalSort('cost', rows[4], rows[1])).toBeGreaterThan(0);
});
@@ -68,10 +68,10 @@ test('numericalSort sorts correctly', () => {
* In the case the sorter cannot perform the comparison it should return undefined and the next sort step will proceed without error
*/
test('alphabeticalSort bad inputs no errors', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(alphabeticalSort('name', null, null)).toBe(undefined);
// incorrect non-object values
- // @ts-ignore
+ // @ts-expect-error
expect(alphabeticalSort('name', 3, [])).toBe(undefined);
// incorrect object values without specified key
expect(alphabeticalSort('name', {}, {})).toBe(undefined);
@@ -79,7 +79,7 @@ test('alphabeticalSort bad inputs no errors', () => {
expect(
alphabeticalSort(
'name',
- // @ts-ignore
+ // @ts-expect-error
{ name: { title: 'the name attribute should not be an object' } },
{ name: 'Doug' },
),
@@ -87,12 +87,12 @@ test('alphabeticalSort bad inputs no errors', () => {
});
test('numericalSort bad inputs no errors', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(numericalSort('name', undefined, undefined)).toBe(NaN);
- // @ts-ignore
+ // @ts-expect-error
expect(numericalSort('name', null, null)).toBe(NaN);
// incorrect non-object values
- // @ts-ignore
+ // @ts-expect-error
expect(numericalSort('name', 3, [])).toBe(NaN);
// incorrect object values without specified key
expect(numericalSort('name', {}, {})).toBe(NaN);
@@ -100,7 +100,7 @@ test('numericalSort bad inputs no errors', () => {
expect(
numericalSort(
'name',
- // @ts-ignore
+ // @ts-expect-error
{ name: { title: 'the name attribute should not be an object' } },
{ name: 'Doug' },
),
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts
index fc60729dc98..1b0bc3505ef 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts
+++ b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts
@@ -46,12 +46,12 @@ test('withinRange unsupported negative numbers', async () => {
test('withinRange invalid inputs', async () => {
// Invalid inputs should return falsy and not throw an error
// We need ts-ignore here to be able to pass invalid values and pass linting
- // @ts-ignore
+ // @ts-expect-error
expect(withinRange(null, 60, undefined)).toBeFalsy();
- // @ts-ignore
+ // @ts-expect-error
expect(withinRange([], 'hello', {})).toBeFalsy();
- // @ts-ignore
+ // @ts-expect-error
expect(withinRange([], undefined, {})).toBeFalsy();
- // @ts-ignore
+ // @ts-expect-error
expect(withinRange([], 'hello', {})).toBeFalsy();
});
diff --git a/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx
index 5012e1426f2..88278227a19 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx
@@ -60,7 +60,7 @@ beforeEach(() => {
parent: { child: 'Nested Value 3' },
},
];
- // @ts-ignore
+ // @ts-expect-error
const tableHookResult = renderHook(() => useTable({ columns, data }));
tableHook = tableHookResult.result.current;
defaultProps = {
diff --git a/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/index.tsx
index d7c86a492e9..6439a528d6e 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/index.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/index.tsx
@@ -47,7 +47,7 @@ export const TelemetryPixel = ({
const pixelPath = `https://apachesuperset.gateway.scarf.sh/pixel/${PIXEL_ID}/${version}/${sha}/${build}`;
return process.env.SCARF_ANALYTICS === 'false' ? null : (
<img
- // @ts-ignore
+ // @ts-expect-error
referrerPolicy="no-referrer-when-downgrade"
src={pixelPath}
width={0}
diff --git a/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneOptionsCache.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneOptionsCache.test.tsx
index 0c86e4f9ea9..ea02a63546e 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneOptionsCache.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneOptionsCache.test.tsx
@@ -241,7 +241,7 @@ test('uses queueMicrotask when available', async () => {
test('falls back to setTimeout when queueMicrotask is not available', async () => {
const originalQueueMicrotask = global.queueMicrotask;
- // @ts-ignore - temporarily remove queueMicrotask for testing
+ // @ts-expect-error - temporarily remove queueMicrotask for testing
delete global.queueMicrotask;
const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
diff --git a/superset-frontend/packages/superset-ui-core/src/math-expression/index.ts b/superset-frontend/packages/superset-ui-core/src/math-expression/index.ts
index bf5ac817cd7..68e0a623f57 100644
--- a/superset-frontend/packages/superset-ui-core/src/math-expression/index.ts
+++ b/superset-frontend/packages/superset-ui-core/src/math-expression/index.ts
@@ -109,7 +109,7 @@ export function evalExpression(expression: string, value: number): number {
parsedExpression = subExpressions[1] ?? subExpressions[0];
// we can ignore the type requirement on `TOKENS`, as value is always `number`
// and doesn't need to consider `number | undefined`.
- // @ts-ignore
+ // @ts-expect-error
return Number(mexp.eval(parsedExpression, TOKENS, { x: value }));
}
diff --git a/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts b/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts
index 5a247d751ed..66f82af0499 100644
--- a/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts
+++ b/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts
@@ -22,7 +22,7 @@
*/
export default class ExtensibleFunction extends Function {
- // @ts-ignore
+ // @ts-expect-error
constructor(fn: Function) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, no-constructor-return
return Object.setPrototypeOf(fn, new.target.prototype);
diff --git a/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts b/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts
index 840cf4c1a18..618b1428366 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts
@@ -63,7 +63,7 @@ export default function normalizeOrderBy(
) {
return {
...cloneQueryObject,
- // @ts-ignore
+ // @ts-expect-error
orderby: [[queryObject.legacy_order_by, isAsc]],
};
}
diff --git a/superset-frontend/packages/superset-ui-core/src/query/processExtraFormData.ts b/superset-frontend/packages/superset-ui-core/src/query/processExtraFormData.ts
index 29eabe75e36..cea1a0d412a 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/processExtraFormData.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/processExtraFormData.ts
@@ -38,7 +38,7 @@ export function overrideExtraFormData(
);
EXTRA_FORM_DATA_OVERRIDE_EXTRA_KEYS.forEach(key => {
if (key in overrideFormData) {
- // @ts-ignore
+ // @ts-expect-error
overriddenExtras[key] = overrideFormData[key];
}
});
diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/SuperChartCore.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/SuperChartCore.test.tsx
index 201a5fccdfd..ba07a9eb829 100644
--- a/superset-frontend/packages/superset-ui-core/test/chart/components/SuperChartCore.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/test/chart/components/SuperChartCore.test.tsx
@@ -86,7 +86,7 @@ describe('SuperChartCore', () => {
});
it('does not render if chartType is not set', async () => {
- // @ts-ignore chartType is required
+ // @ts-expect-error chartType is required
const { container } = render(<SuperChartCore />);
await waitFor(() => {
diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx
index c2b7c43450a..44c62e90e9f 100644
--- a/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx
@@ -129,7 +129,7 @@ describe('reactify(renderFn)', () => {
it('does not try to render if not mounted', () => {
const anotherRenderFn = jest.fn();
const AnotherChart = reactify(anotherRenderFn); // enables valid new AnotherChart() call
- // @ts-ignore
+ // @ts-expect-error
new AnotherChart({ id: 'test' }).execute();
expect(anotherRenderFn).not.toHaveBeenCalled();
});
diff --git a/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts b/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts
index a5e0fe6cc66..b26ab3170c7 100644
--- a/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/connection/SupersetClientClass.test.ts
@@ -529,15 +529,13 @@ describe('SupersetClientClass', () => {
beforeEach(() => {
originalLocation = window.location;
- // @ts-ignore
+ // @ts-expect-error
delete window.location;
- // @ts-ignore
window.location = {
pathname: mockRequestPath,
- // @ts-ignore
search: mockRequestSearch,
href: mockHref,
- };
+ } as unknown as Location;
authSpy = jest
.spyOn(SupersetClientClass.prototype, 'ensureAuth')
.mockImplementation();
@@ -568,13 +566,11 @@ describe('SupersetClientClass', () => {
it('should not redirect again if already on login page', async () => {
const client = new SupersetClientClass({});
- // @ts-ignore
window.location = {
href: '/login?next=something',
pathname: '/login',
- // @ts-ignore
search: '?next=something',
- };
+ } as unknown as Location;
let error;
try {
diff --git a/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts b/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts
index 979c4c1d612..251ecdded09 100644
--- a/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts
@@ -67,18 +67,18 @@ test('CurrencyFormatter:hasValidCurrency', () => {
expect(currencyFormatter.hasValidCurrency()).toBe(true);
const currencyFormatterWithoutPosition = new CurrencyFormatter({
- // @ts-ignore
+ // @ts-expect-error
currency: { symbol: 'USD' },
});
expect(currencyFormatterWithoutPosition.hasValidCurrency()).toBe(true);
const currencyFormatterWithoutSymbol = new CurrencyFormatter({
- // @ts-ignore
+ // @ts-expect-error
currency: { symbolPosition: 'prefix' },
});
expect(currencyFormatterWithoutSymbol.hasValidCurrency()).toBe(false);
- // @ts-ignore
+ // @ts-expect-error
const currencyFormatterWithoutCurrency = new CurrencyFormatter({});
expect(currencyFormatterWithoutCurrency.hasValidCurrency()).toBe(false);
});
@@ -129,12 +129,12 @@ test('CurrencyFormatter:format', () => {
expect(currencyFormatterWithSuffix(VALUE)).toEqual('56.1M $');
const currencyFormatterWithoutPosition = new CurrencyFormatter({
- // @ts-ignore
+ // @ts-expect-error
currency: { symbol: 'USD' },
});
expect(currencyFormatterWithoutPosition(VALUE)).toEqual('56.1M $');
- // @ts-ignore
+ // @ts-expect-error
const currencyFormatterWithoutCurrency = new CurrencyFormatter({});
expect(currencyFormatterWithoutCurrency(VALUE)).toEqual('56.1M');
diff --git a/superset-frontend/packages/superset-ui-core/test/dimension/getBBoxDummyFill.ts b/superset-frontend/packages/superset-ui-core/test/dimension/getBBoxDummyFill.ts
index 8f457933568..1f10944e1b6 100644
--- a/superset-frontend/packages/superset-ui-core/test/dimension/getBBoxDummyFill.ts
+++ b/superset-frontend/packages/superset-ui-core/test/dimension/getBBoxDummyFill.ts
@@ -28,10 +28,10 @@ const textToWidth = {
export const SAMPLE_TEXT = Object.keys(textToWidth);
export function addDummyFill() {
- // @ts-ignore - fix jsdom
+ // @ts-expect-error - fix jsdom
originalFn = SVGElement.prototype.getBBox;
- // @ts-ignore - fix jsdom
+ // @ts-expect-error - fix jsdom
SVGElement.prototype.getBBox = function getBBox() {
let width =
textToWidth[this.textContent as keyof typeof textToWidth] || 200;
@@ -78,6 +78,6 @@ export function addDummyFill() {
}
export function removeDummyFill() {
- // @ts-ignore - fix jsdom
+ // @ts-expect-error - fix jsdom
SVGElement.prototype.getBBox = originalFn;
}
diff --git a/superset-frontend/packages/superset-ui-core/test/dimension/mergeMargin.test.ts b/superset-frontend/packages/superset-ui-core/test/dimension/mergeMargin.test.ts
index 6567605efe7..86e9194efe0 100644
--- a/superset-frontend/packages/superset-ui-core/test/dimension/mergeMargin.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/dimension/mergeMargin.test.ts
@@ -187,7 +187,7 @@ describe('mergeMargin(margin1, margin2, mode?)', () => {
mergeMargin(
{
top: 10,
- // @ts-ignore to let us pass `null` for testing
+ // @ts-expect-error to let us pass `null` for testing
left: null,
bottom: 20,
right: NaN,
diff --git a/superset-frontend/packages/superset-ui-core/test/models/ExtensibleFunction.test.ts b/superset-frontend/packages/superset-ui-core/test/models/ExtensibleFunction.test.ts
index 11db53fd9af..2a52d0bfb5b 100644
--- a/superset-frontend/packages/superset-ui-core/test/models/ExtensibleFunction.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/models/ExtensibleFunction.test.ts
@@ -54,9 +54,9 @@ describe('ExtensibleFunction', () => {
x: unknown;
constructor(x: unknown) {
- // @ts-ignore
+ // @ts-expect-error
super(function customName() {
- // @ts-ignore
+ // @ts-expect-error
return customName.x;
}); // named function
this.x = x;
diff --git a/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatter.test.ts b/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatter.test.ts
index 7cb11444448..e8bee2dcffd 100644
--- a/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatter.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatter.test.ts
@@ -24,7 +24,7 @@ describe('NumberFormatter', () => {
it('requires config.id', () => {
expect(
() =>
- // @ts-ignore
+ // @ts-expect-error
new NumberFormatter({
formatFunc: () => '',
}),
@@ -33,7 +33,7 @@ describe('NumberFormatter', () => {
it('requires config.formatFunc', () => {
expect(
() =>
- // @ts-ignore
+ // @ts-expect-error
new NumberFormatter({
id: 'my_format',
}),
diff --git a/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatterRegistry.test.ts b/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatterRegistry.test.ts
index 2ff49f155c0..d2b1521f903 100644
--- a/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatterRegistry.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatterRegistry.test.ts
@@ -49,7 +49,7 @@ describe('NumberFormatterRegistry', () => {
});
it('falls back to default format if format is null', () => {
registry.setDefaultKey('.1f');
- // @ts-ignore
+ // @ts-expect-error
const formatter = registry.get(null);
expect(formatter.format(100)).toEqual('100.0');
});
diff --git a/superset-frontend/packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts b/superset-frontend/packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts
index 951ab039c5a..e438167a30d 100644
--- a/superset-frontend/packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts
@@ -21,7 +21,7 @@ import { createD3NumberFormatter } from '@superset-ui/core';
describe('createD3NumberFormatter(config)', () => {
it('requires config.formatString', () => {
- // @ts-ignore -- intentionally pass invalid input
+ // @ts-expect-error -- intentionally pass invalid input
expect(() => createD3NumberFormatter({})).toThrow();
});
describe('config.formatString', () => {
diff --git a/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts b/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts
index 5e39c6f8cfe..027537b025c 100644
--- a/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts
@@ -151,7 +151,7 @@ describe('makeApi()', () => {
makeApi({
method: 'POST',
endpoint: '/test-formdata',
- // @ts-ignore
+ // @ts-expect-error
requestType: 'text',
});
}).toThrow('Invalid request payload type');
diff --git a/superset-frontend/packages/superset-ui-core/test/query/getClientErrorObject.test.ts b/superset-frontend/packages/superset-ui-core/test/query/getClientErrorObject.test.ts
index 1abbf5c3065..8f24e508dcc 100644
--- a/superset-frontend/packages/superset-ui-core/test/query/getClientErrorObject.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/query/getClientErrorObject.test.ts
@@ -120,7 +120,7 @@ test('Handles Response that contains raw html be parsed as text', async () => {
test('Handles TypeError Response', async () => {
const error = new TypeError('Failed to fetch');
- // @ts-ignore
+ // @ts-expect-error
const errorObj = await getClientErrorObject(error);
expect(errorObj).toMatchObject({ error: 'Network error' });
});
@@ -184,15 +184,15 @@ test('Handles error with status text and message', async () => {
const statusText = 'status';
const message = 'message';
- // @ts-ignore
+ // @ts-expect-error
expect(await getClientErrorObject({ statusText, message })).toMatchObject({
error: statusText,
});
- // @ts-ignore
+ // @ts-expect-error
expect(await getClientErrorObject({ message })).toMatchObject({
error: message,
});
- // @ts-ignore
+ // @ts-expect-error
expect(await getClientErrorObject({})).toMatchObject({
error: 'An error occurred',
});
diff --git a/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts b/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts
index 57f234ebc85..0bc8da67e4f 100644
--- a/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts
@@ -183,7 +183,7 @@ describe('normalizeOrderBy', () => {
datasource: '5__table',
viz_type: VizType.Table,
time_range: '1 year ago : 2013',
- // @ts-ignore
+ // @ts-expect-error
orderby: [['count(*)', 'true']],
};
expect(normalizeOrderBy(query)).not.toHaveProperty('orderby');
diff --git a/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatter.test.ts b/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatter.test.ts
index e6353e856d0..6334c93d4e4 100644
--- a/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatter.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatter.test.ts
@@ -24,7 +24,7 @@ describe('TimeFormatter', () => {
it('requires config.id', () => {
expect(
() =>
- // @ts-ignore -- intentionally pass invalid input
+ // @ts-expect-error -- intentionally pass invalid input
new TimeFormatter({
formatFunc: () => 'test',
}),
@@ -33,7 +33,7 @@ describe('TimeFormatter', () => {
it('requires config.formatFunc', () => {
expect(
() =>
- // @ts-ignore -- intentionally pass invalid input
+ // @ts-expect-error -- intentionally pass invalid input
new TimeFormatter({
id: 'my_format',
}),
diff --git a/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatterRegistry.test.ts b/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatterRegistry.test.ts
index 57b659d7400..8ae78b49730 100644
--- a/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatterRegistry.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/time-format/TimeFormatterRegistry.test.ts
@@ -45,7 +45,7 @@ describe('TimeFormatterRegistry', () => {
});
it('falls back to default format if format is null', () => {
registry.setDefaultKey(TimeFormats.INTERNATIONAL_DATE);
- // @ts-ignore
+ // @ts-expect-error
const formatter = registry.get(null);
expect(formatter.format(PREVIEW_TIME)).toEqual('14/02/2017');
});
diff --git a/superset-frontend/packages/superset-ui-core/test/time-format/factories/createD3TimeFormatter.test.ts b/superset-frontend/packages/superset-ui-core/test/time-format/factories/createD3TimeFormatter.test.ts
index a47e0e2f5b4..22a45c9e797 100644
--- a/superset-frontend/packages/superset-ui-core/test/time-format/factories/createD3TimeFormatter.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/time-format/factories/createD3TimeFormatter.test.ts
@@ -71,9 +71,9 @@ const thLocale: TimeLocaleDefinition = {
describe('createD3TimeFormatter(config)', () => {
it('requires config.formatString', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(() => createD3TimeFormatter()).toThrow();
- // @ts-ignore
+ // @ts-expect-error
expect(() => createD3TimeFormatter({})).toThrow();
});
describe('config.useLocalTime', () => {
diff --git a/superset-frontend/packages/superset-ui-core/test/utils/getSelectedText.test.ts b/superset-frontend/packages/superset-ui-core/test/utils/getSelectedText.test.ts
index 75682e9e747..7737cd36fb3 100644
--- a/superset-frontend/packages/superset-ui-core/test/utils/getSelectedText.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/utils/getSelectedText.test.ts
@@ -27,7 +27,7 @@ test('Returns null if Selection object is null', () => {
test('Returns selection text if Selection object is not null', () => {
jest
.spyOn(window, 'getSelection')
- // @ts-ignore
+ // @ts-expect-error
.mockImplementationOnce(() => ({ toString: () => 'test string' }));
expect(getSelectedText()).toEqual('test string');
jest.restoreAllMocks();
diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts
index b5f12f34855..0d4daf339f9 100644
--- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts
+++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts
@@ -22,8 +22,8 @@ import {
TableChartFormData,
TableChartProps,
} from '@superset-ui/plugin-chart-table';
-// @ts-ignore
// eslint-disable-next-line import/extensions
+// @ts-ignore -- TS6307: this file is outside the tsconfig project scope, @ts-expect-error does not suppress project-level errors
import birthNamesJson from './birthNames.json';
export const birthNames = birthNamesJson as unknown as TableChartProps;
diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx
index 0fdc53f2b97..f0f4d34a959 100644
--- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx
+++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx
@@ -224,7 +224,7 @@ const DeckMulti = (props: DeckMultiProps) => {
const createLayerFromData = useCallback(
(subslice: JsonObject, json: JsonObject): Layer =>
- // @ts-ignore TODO(hainenber): define proper type for `form_data.viz_type` and call signature for functions in layerGenerators.
+ // @ts-expect-error TODO(hainenber): define proper type for `form_data.viz_type` and call signature for functions in layerGenerators.
layerGenerators[subslice.form_data.viz_type]({
formData: subslice.form_data,
payload: json,
diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Grid/Grid.tsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Grid/Grid.tsx
index 72faceb32a8..9fd68782549 100644
--- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Grid/Grid.tsx
+++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Grid/Grid.tsx
@@ -105,9 +105,9 @@ export const getLayer: GetLayerType<GridLayer> = function ({
: undefined,
colorRange,
outline: false,
- // @ts-ignore
+ // @ts-expect-error
getElevationValue: aggFunc,
- // @ts-ignore
+ // @ts-expect-error
getColorValue: colorAggFunc,
...commonLayerProps({
formData: fd,
@@ -158,7 +158,7 @@ export const getHighlightLayer: GetLayerType<GridLayer> = function ({
colorRange: [TRANSPARENT_COLOR_ARRAY, HIGHLIGHT_COLOR_ARRAY],
colorAggregation: 'MAX',
outline: false,
- // @ts-ignore
+ // @ts-expect-error
getElevationValue: aggFunc,
getColorWeight: colorAggFunc,
opacity: 1,
diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Hex/Hex.tsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Hex/Hex.tsx
index 1f1e35f3dc9..4472444ebb4 100644
--- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Hex/Hex.tsx
+++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Hex/Hex.tsx
@@ -106,9 +106,9 @@ export const getLayer: GetLayerType<HexagonLayer> = function ({
: undefined,
colorRange,
outline: false,
- // @ts-ignore
+ // @ts-expect-error
getElevationValue: aggFunc,
- // @ts-ignore
+ // @ts-expect-error
getColorValue: colorAggFunc,
...commonLayerProps({
formData: fd,
@@ -159,7 +159,7 @@ export const getHighlightLayer: GetLayerType<HexagonLayer> = function ({
colorRange: [TRANSPARENT_COLOR_ARRAY, HIGHLIGHT_COLOR_ARRAY],
colorAggregation: 'MAX',
outline: false,
- // @ts-ignore
+ // @ts-expect-error
getElevationValue: aggFunc,
getColorWeight: colorAggFunc,
opacity: 1,
diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/formatValue.ts b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/formatValue.ts
index d84fe3fddf6..a6772d1e13a 100644
--- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/formatValue.ts
+++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/formatValue.ts
@@ -103,7 +103,7 @@ export const valueFormatter = (
};
export const valueGetter = (params: ValueGetterParams, col: InputColumn) => {
- // @ts-ignore
+ // @ts-expect-error
if (params?.colDef?.isMain) {
const modifiedColId = `Main ${params.column.getColId()}`;
return params.data[modifiedColId];
diff --git a/superset-frontend/plugins/plugin-chart-cartodiagram/src/util/layerUtil.tsx b/superset-frontend/plugins/plugin-chart-cartodiagram/src/util/layerUtil.tsx
index 65e608bd757..4af5066efca 100644
--- a/superset-frontend/plugins/plugin-chart-cartodiagram/src/util/layerUtil.tsx
+++ b/superset-frontend/plugins/plugin-chart-cartodiagram/src/util/layerUtil.tsx
@@ -133,7 +133,6 @@ export const createWfsLayer = async (wfsLayerConf: WfsLayerConf) => {
return new VectorLayer({
source: wfsSource,
- // @ts-ignore
style: writeStyleResult?.output,
});
};
diff --git a/superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts b/superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts
index d2912105e02..20c415df655 100644
--- a/superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts
+++ b/superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts
@@ -72,10 +72,10 @@ describe('layerUtil', () => {
const wfsLayer = await createWfsLayer(wfsLayerConf);
const style = wfsLayer!.getStyle();
- // @ts-ignore
+ // @ts-expect-error
expect(style!.length).toEqual(3);
- // @ts-ignore upgrade `ol` package for better type of StyleLike type.
+ // @ts-expect-error upgrade `ol` package for better type of StyleLike type.
const colorAtLayer = style![1].getImage().getFill().getColor();
expect(colorToExpect).toEqual(colorAtLayer);
});
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx
index df201008b1f..3458d3c2b18 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx
@@ -192,7 +192,7 @@ function BigNumberVis({
const renderHeader = (maxHeight: number) => {
const { bigNumber, width, colorThresholdFormatters, onContextMenu } = props;
- // @ts-ignore
+ // @ts-expect-error
const text = bigNumber === null ? t('No data') : headerFormatter(bigNumber);
const hasThresholdColorFormatter =
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
index 7b3337fdb11..90dd51f6c01 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
@@ -217,7 +217,7 @@ export default function transformProps(
if (data.length > 0) {
const reversedData = [...sortedData].reverse();
- // @ts-ignore
+ // @ts-expect-error
trendLineData = showTrendLine ? reversedData : undefined;
}
@@ -379,7 +379,7 @@ export default function transformProps(
width,
height,
bigNumber,
- // @ts-ignore
+ // @ts-expect-error
bigNumberFallback,
className,
headerFormatter: yAxisFormatter,
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/transformProps.ts
index ba7f0ca0166..2ee08dd3a9e 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/transformProps.ts
@@ -202,7 +202,7 @@ export default function transformProps(
tooltip: {
...getDefaultTooltip(refs),
formatter: (param: CallbackDataParams) => {
- // @ts-ignore
+ // @ts-expect-error
const {
value,
name,
@@ -239,7 +239,7 @@ export default function transformProps(
},
},
},
- // @ts-ignore
+ // @ts-expect-error
...outlierData,
];
const addYAxisTitleOffset = !!yAxisTitle;
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/types.ts
index 6a7e79d2297..84c9c0c5a18 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BoxPlot/types.ts
@@ -47,7 +47,7 @@ export type BoxPlotFormXTickLayout =
| 'flat'
| 'staggered';
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: BoxPlotQueryFormData = {
...DEFAULT_TITLE_FORM_DATA,
};
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts
index fd3cce40c08..5f6e4a1e853 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts
@@ -264,7 +264,7 @@ export default function transformProps(
fontWeight: 'bold',
},
},
- // @ts-ignore
+ // @ts-expect-error
data: transformedData,
},
];
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts
index a03d0ec01f3..5c1183d1fc5 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/types.ts
@@ -59,7 +59,7 @@ export interface EchartsFunnelChartProps extends BaseChartProps<EchartsFunnelFor
formData: EchartsFunnelFormData;
}
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: EchartsFunnelFormData = {
...DEFAULT_LEGEND_FORM_DATA,
groupby: [],
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts
index cd4f2610f7d..fdee23c0076 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts
@@ -350,7 +350,7 @@ export default function transformProps(
axisTick,
pointer,
detail,
- // @ts-ignore
+ // @ts-expect-error
tooltip,
radius:
Math.min(width, height) / 2 - axisLabelDistance - axisTickDistance,
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Graph/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Graph/types.ts
index 8c5c67f84ac..d86e7bf6a20 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Graph/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Graph/types.ts
@@ -59,7 +59,7 @@ export type EChartGraphNode = Omit<GraphNodeItemOption, 'value'> & {
tooltip?: Pick<SeriesTooltipOption, 'formatter'>;
};
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: EchartsGraphFormData = {
...DEFAULT_LEGEND_FORM_DATA,
source: '',
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx
index 390b380675e..6dbe6d7e035 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx
@@ -75,7 +75,6 @@ export default function EchartsMixedTimeseries({
return {
dataMask: {
extraFormData: {
- // @ts-ignore
filters:
values.length === 0
? []
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts
index 108d41396a9..33bf39c11db 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts
@@ -82,7 +82,7 @@ export default class EchartsTimeseriesChartPlugin extends EchartsChartPlugin<
],
queryObjectCount: 2,
},
- // @ts-ignore
+ // @ts-expect-error
transformProps,
});
}
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
index 3a9f945465f..8c9ef338edf 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
@@ -756,7 +756,7 @@ export default function transformProps(
legendState,
chartPadding,
),
- // @ts-ignore
+ // @ts-expect-error
data: series
.filter(
entry =>
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
index c5e363ecb47..3000c995892 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
@@ -93,7 +93,7 @@ export type EchartsMixedTimeseriesFormData = QueryFormData & {
} & LegendFormData &
TitleFormData;
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: EchartsMixedTimeseriesFormData = {
...DEFAULT_LEGEND_FORM_DATA,
annotationLayers: [],
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts
index 45d9b1119fe..c869c6b5112 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts
@@ -65,7 +65,7 @@ export interface EchartsPieChartProps extends BaseChartProps<EchartsPieFormData>
formData: EchartsPieFormData;
}
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: EchartsPieFormData = {
...DEFAULT_LEGEND_FORM_DATA,
donut: false,
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/types.ts
index 82719354a98..c3d5dd6cee4 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Radar/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Radar/types.ts
@@ -65,7 +65,7 @@ export interface EchartsRadarChartProps extends BaseChartProps<EchartsRadarFormD
formData: EchartsRadarFormData;
}
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: EchartsRadarFormData = {
...DEFAULT_LEGEND_FORM_DATA,
groupby: [],
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx
index bd261ba0a2d..87778a6b867 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx
@@ -339,7 +339,7 @@ export default function EchartsTimeseries({
if (echartInstance?.containPixel('grid', pointInPixel)) {
// do not trigger if click unstacked chart's blank area
if (!stack && params.target?.type === 'ec-polygon') return;
- // @ts-ignore
+ // @ts-expect-error
const globalModel = echartInstance.getModel();
const model = getModelInfo(params.target, globalModel);
if (model) {
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts
index e00f62b15a6..90c05008b5a 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts
@@ -33,7 +33,7 @@ import {
// } from '../constants';
import { defaultXAxis } from '../defaults';
-// @ts-ignore
+// @ts-expect-error
export const DEFAULT_FORM_DATA: EchartsTimeseriesFormData = {
// ...DEFAULT_LEGEND_FORM_DATA, // TODO: figure out why these break things for stories (e.g. Bubble Chart)
// Here are the contents of DEFAULT_LEGEND_FORM_DATA:
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
index 34dfcb34c45..70e4bc44f25 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
@@ -340,11 +340,11 @@ export function transformSeries(
yAxisIndex,
name: forecastSeries.name,
itemStyle,
- // @ts-ignore
+ // @ts-expect-error
type: plotType,
smooth: seriesType === 'smooth',
triggerLineEvent: true,
- // @ts-ignore
+ // @ts-expect-error
step: ['start', 'middle', 'end'].includes(seriesType as string)
? seriesType
: undefined,
@@ -474,7 +474,7 @@ export function transformIntervalAnnotation(
position: 'insideTop',
verticalAlign: 'top',
fontWeight: 'bold',
- // @ts-ignore
+ // @ts-expect-error
emphasis: {
position: 'insideTop',
verticalAlign: 'top',
@@ -484,7 +484,6 @@ export function transformIntervalAnnotation(
: {
show: false,
color: theme.colorTextLabel,
- // @ts-ignore
emphasis: {
fontWeight: 'bold',
show: true,
@@ -555,7 +554,7 @@ export function transformEventAnnotation(
position: 'insideEndTop',
fontWeight: 'bold',
formatter: (params: CallbackDataParams) => params.name,
- // @ts-ignore
+ // @ts-expect-error
emphasis: {
backgroundColor: theme.colorPrimaryBgHover,
},
@@ -564,7 +563,6 @@ export function transformEventAnnotation(
show: false,
color: theme.colorTextLabel,
position: 'insideEndTop',
- // @ts-ignore
emphasis: {
formatter: (params: CallbackDataParams) => params.name,
fontWeight: 'bold',
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
index 0c0d5c3b87f..40f1b87fd43 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
@@ -134,7 +134,7 @@ describe('BigNumberWithTrendline', () => {
expect(transformed.bigNumberFallback).toBeNull();
// should successfully formatTime by granularity
- // @ts-ignore
+ // @ts-expect-error
expect(transformed.formatTime(new Date('2020-01-01'))).toStrictEqual(
'2020-01-01 00:00:00',
);
@@ -156,7 +156,7 @@ describe('BigNumberWithTrendline', () => {
},
};
const transformed = transformProps(propsWithDatasource);
- // @ts-ignore
+ // @ts-expect-error
expect(transformed.headerFormatter(transformed.bigNumber)).toStrictEqual(
'1.23',
);
@@ -182,7 +182,7 @@ describe('BigNumberWithTrendline', () => {
},
};
const transformed = transformProps(propsWithDatasource);
- // @ts-ignore
+ // @ts-expect-error
expect(transformed.headerFormatter(transformed.bigNumber)).toStrictEqual(
'$ 1.23',
);
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/controlPanel.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/controlPanel.test.ts
index 7be75638686..4c560ea9ff3 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/controlPanel.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/controlPanel.test.ts
@@ -52,7 +52,7 @@ const mockControls = (
return {
controls: {
- // @ts-ignore
+ // @ts-expect-error
x_axis: {
value: xAxisColumn,
options: options,
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/transformProps.test.ts
index 560f5c19ea1..f69ac1f4d93 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/transformProps.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Scatter/transformProps.test.ts
@@ -70,7 +70,6 @@ describe('Scatter Chart X-axis Time Formatting', () => {
});
const transformedProps = transformProps(
- // @ts-ignore
chartProps as EchartsTimeseriesChartProps,
);
@@ -92,7 +91,6 @@ describe('Scatter Chart X-axis Time Formatting', () => {
});
const transformedProps = transformProps(
- // @ts-ignore
chartProps as EchartsTimeseriesChartProps,
);
@@ -146,7 +144,6 @@ describe('Scatter Chart X-axis Number Formatting', () => {
});
const transformedProps = transformProps(
- // @ts-ignore
chartProps as EchartsTimeseriesChartProps,
);
@@ -169,7 +166,6 @@ describe('Scatter Chart X-axis Number Formatting', () => {
});
const transformedProps = transformProps(
- // @ts-ignore
chartProps as EchartsTimeseriesChartProps,
);
diff --git a/superset-frontend/plugins/plugin-chart-table/test/sortAlphanumericCaseInsensitive.test.ts b/superset-frontend/plugins/plugin-chart-table/test/sortAlphanumericCaseInsensitive.test.ts
index 356596ec210..663bcc0b6e0 100644
--- a/superset-frontend/plugins/plugin-chart-table/test/sortAlphanumericCaseInsensitive.test.ts
+++ b/superset-frontend/plugins/plugin-chart-table/test/sortAlphanumericCaseInsensitive.test.ts
@@ -80,7 +80,7 @@ const testData = [
describe('sortAlphanumericCaseInsensitive', () => {
it('Sort rows', () => {
const sorted = [...testData].sort((a, b) =>
- // @ts-ignore
+ // @ts-expect-error
sortAlphanumericCaseInsensitive(a, b, 'col'),
);
diff --git a/superset-frontend/spec/helpers/ProviderWrapper.tsx b/superset-frontend/spec/helpers/ProviderWrapper.tsx
index d8d63cf3de6..87bab27c8cb 100644
--- a/superset-frontend/spec/helpers/ProviderWrapper.tsx
+++ b/superset-frontend/spec/helpers/ProviderWrapper.tsx
@@ -18,8 +18,9 @@
*/
import { ThemeProvider } from '@apache-superset/core/ui';
-import { BrowserRouter as Router, Route } from 'react-router-dom';
+import { BrowserRouter as Router } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
export function ProviderWrapper(props: any) {
const { children, theme } = props;
@@ -27,10 +28,7 @@ export function ProviderWrapper(props: any) {
return (
<ThemeProvider theme={theme}>
<Router>
- <QueryParamProvider
- ReactRouterRoute={Route}
- stringifyOptions={{ encode: false }}
- >
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
{children}
</QueryParamProvider>
</Router>
diff --git a/superset-frontend/spec/helpers/testing-library.tsx b/superset-frontend/spec/helpers/testing-library.tsx
index 1a841a32483..21abd6a44d0 100644
--- a/superset-frontend/spec/helpers/testing-library.tsx
+++ b/superset-frontend/spec/helpers/testing-library.tsx
@@ -39,6 +39,7 @@ import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import reducerIndex from 'spec/helpers/reducerIndex';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import { configureStore, Store } from '@reduxjs/toolkit';
import { api } from 'src/hooks/apiResources/queryApi';
import userEvent from '@testing-library/user-event';
@@ -109,7 +110,11 @@ export function createWrapper(options?: Options) {
}
if (useQueryParams) {
- result = <QueryParamProvider>{result}</QueryParamProvider>;
+ result = (
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
+ {result}
+ </QueryParamProvider>
+ );
}
if (useRouter) {
diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.ts b/superset-frontend/src/SqlLab/actions/sqlLab.test.ts
index bf15df3d805..e9fab1d19ff 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.test.ts
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.ts
@@ -20,9 +20,11 @@ import sinon from 'sinon';
import fetchMock from 'fetch-mock';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
+import type { ThunkDispatch } from 'redux-thunk';
+import type { AnyAction } from 'redux';
import { waitFor } from 'spec/helpers/testing-library';
import * as actions from 'src/SqlLab/actions/sqlLab';
-import type { QueryEditor, Table } from 'src/SqlLab/types';
+import type { QueryEditor, Table, SqlLabRootState } from 'src/SqlLab/types';
import { LOG_EVENT } from 'src/logger/actions';
import {
defaultQueryEditor,
@@ -36,9 +38,14 @@ import { ToastType } from '../../components/MessageToasts/types';
const isFeatureEnabledMock = isFeatureEnabled as unknown as jest.Mock;
const query = { ...queryFixture, id: queryId } as any;
+// Cast fixture to satisfy SqlLabRootState for getState callbacks in thunk tests
+const typedInitialState = initialState as unknown as SqlLabRootState;
+
+type DispatchExts = ThunkDispatch<SqlLabRootState, undefined, AnyAction>;
const middlewares = [thunk];
-const mockStore = configureMockStore(middlewares);
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+const mockStore = configureMockStore<any, DispatchExts>(middlewares);
jest.mock('nanoid', () => ({
nanoid: () => 'abcd',
@@ -70,7 +77,7 @@ describe('getUpToDateQuery', () => {
queryEditors: [queryEditor],
unsavedQueryEditor: {},
},
- };
+ } as unknown as SqlLabRootState;
expect(actions.getUpToDateQuery(state, outOfUpdatedQueryEditor)).toEqual(
queryEditor,
);
@@ -122,7 +129,7 @@ describe('async actions', () => {
const makeRequest = () => {
const request = actions.saveQuery(query, queryId);
- return request(dispatch, () => initialState);
+ return request(dispatch, () => typedInitialState, undefined);
};
test('posts to the correct url', () => {
@@ -418,7 +425,7 @@ describe('async actions', () => {
const makeRequest = () => {
const store = mockStore(initialState);
const request = actions.fetchQueryResults(query);
- return request(dispatch, store.getState);
+ return request(dispatch, store.getState, undefined);
};
test('makes the fetch request', () => {
@@ -488,7 +495,7 @@ describe('async actions', () => {
describe('runQuery without query params', () => {
const makeRequest = () => {
const request = actions.runQuery(query);
- return request(dispatch, () => initialState);
+ return request(dispatch, () => typedInitialState, undefined);
};
test('makes the fetch request', () => {
@@ -523,7 +530,7 @@ describe('async actions', () => {
const expectedActionTypes = [actions.START_QUERY, actions.QUERY_SUCCESS];
const { dispatch } = store;
const request = actions.runQuery(query);
- return request(dispatch, () => initialState).then(() => {
+ return request(dispatch, () => typedInitialState, undefined).then(() => {
expect(store.getActions().map(a => a.type)).toEqual(
expectedActionTypes,
);
@@ -554,7 +561,7 @@ describe('async actions', () => {
];
const { dispatch } = store;
const request = actions.runQuery(query);
- return request(dispatch, () => initialState).then(() => {
+ return request(dispatch, () => typedInitialState, undefined).then(() => {
const actions = store.getActions();
expect(actions.map(a => a.type)).toEqual(expectedActionTypes);
expect(actions[1].payload.eventData.issue_codes).toEqual([1000, 1001]);
@@ -578,7 +585,7 @@ describe('async actions', () => {
const makeRequest = () => {
const request = actions.runQuery(query);
- return request(dispatch, () => initialState);
+ return request(dispatch, () => typedInitialState, undefined);
};
test('makes the fetch request', async () => {
@@ -609,7 +616,7 @@ describe('async actions', () => {
};
const store = mockStore(state);
const request = actions.reRunQuery(query);
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()[0].query.id).toEqual('abcd');
});
});
@@ -625,7 +632,7 @@ describe('async actions', () => {
const makeRequest = () => {
const request = actions.postStopQuery(baseQuery);
- return request(dispatch);
+ return request(dispatch, () => typedInitialState, undefined);
};
test('makes the fetch request', () => {
@@ -693,7 +700,7 @@ describe('async actions', () => {
},
];
const request = actions.cloneQueryToNewTab(query, true);
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()).toEqual(expectedActions);
});
@@ -741,7 +748,7 @@ describe('async actions', () => {
const request = actions.popSavedQuery(String(id));
const { dispatch } = store;
- return request(dispatch, () => initialState);
+ return request(dispatch, () => typedInitialState, undefined);
};
beforeEach(() => {
@@ -862,7 +869,7 @@ describe('async actions', () => {
},
];
const request = actions.addNewQueryEditor();
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()).toEqual(expectedActions);
});
});
@@ -1162,7 +1169,7 @@ describe('async actions', () => {
},
});
const request = actions.queryEditorSetAndSaveSql(queryEditor, sql);
- return request(store.dispatch, store.getState).then(() => {
+ return request(store.dispatch, store.getState, undefined).then(() => {
expect(store.getActions()).toEqual(expectedActions);
expect(
fetchMock.callHistory.calls(updateTabStateEndpoint),
@@ -1185,7 +1192,7 @@ describe('async actions', () => {
},
});
const request = actions.queryEditorSetAndSaveSql(queryEditor, sql);
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()).toEqual(expectedActions);
expect(
@@ -1262,7 +1269,7 @@ describe('async actions', () => {
catalogName,
schemaName,
);
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()[0]).toEqual(
expect.objectContaining({
table: expect.objectContaining({
@@ -1300,7 +1307,7 @@ describe('async actions', () => {
catalogName,
schemaName,
);
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()[0]).toEqual(
expect.objectContaining({
@@ -1339,7 +1346,7 @@ describe('async actions', () => {
catalogName,
schemaName,
);
- request(store.dispatch, store.getState);
+ request(store.dispatch, store.getState, undefined);
expect(store.getActions()[0]).toEqual(
expect.objectContaining({
@@ -1371,7 +1378,7 @@ describe('async actions', () => {
tableName as any,
schemaName,
);
- return request(store.dispatch, store.getState).then(() => {
+ return request(store.dispatch, store.getState, undefined).then(() => {
expect(store.getActions().map(a => a.type)).toEqual(
expectedActionTypes,
);
@@ -1434,7 +1441,7 @@ describe('async actions', () => {
catalog: catalogName,
schema: schemaName,
});
- return request(store.dispatch, store.getState).then(() => {
+ return request(store.dispatch, store.getState, undefined).then(() => {
expect(store.getActions().map(a => a.type)).toEqual(
expectedActionTypes,
);
@@ -1460,7 +1467,7 @@ describe('async actions', () => {
},
true,
);
- return request(store.dispatch, store.getState).then(() => {
+ return request(store.dispatch, store.getState, undefined).then(() => {
expect(store.getActions().map(a => a.type)).toEqual(
expectedActionTypes,
);
diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.ts b/superset-frontend/src/SqlLab/actions/sqlLab.ts
index 99858a99e64..3fe01a03071 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.ts
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.ts
@@ -18,7 +18,8 @@
*/
import { nanoid } from 'nanoid';
import rison from 'rison';
-import type { ThunkAction } from 'redux-thunk';
+import type { AnyAction } from 'redux';
+import type { ThunkAction, ThunkDispatch } from 'redux-thunk';
import type { QueryColumn, SupersetError } from '@superset-ui/core';
import {
FeatureFlag,
@@ -38,6 +39,7 @@ import {
addWarningToast as addWarningToastAction,
} from 'src/components/MessageToasts/actions';
import { LOG_ACTIONS_SQLLAB_FETCH_FAILED_QUERY } from 'src/logger/LogUtils';
+import type { BootstrapData } from 'src/types/bootstrapTypes';
import getBootstrapData from 'src/utils/getBootstrapData';
import { logEvent } from 'src/logger/actions';
import type { QueryEditor, SqlLabRootState, Table } from '../types';
@@ -223,20 +225,26 @@ export interface SqlLabAction {
offline?: boolean;
datasource?: unknown;
clientId?: string;
- result?: { remoteId: number };
+ result?: Record<string, unknown>;
prepend?: boolean;
- json?: { result: unknown };
+ json?: Record<string, unknown>;
oldQueryId?: string;
newQuery?: { id: string };
}
+// Use AnyAction for ThunkAction/ThunkDispatch to maintain compatibility with
+// redux-mock-store and standard Redux patterns. SqlLabAction is used for plain
+// action creator return types where the shape is known.
type SqlLabThunkAction<R = void> = ThunkAction<
R,
SqlLabRootState,
- unknown,
- SqlLabAction
+ undefined,
+ AnyAction
>;
+type AppDispatch = ThunkDispatch<SqlLabRootState, undefined, AnyAction>;
+type GetState = () => SqlLabRootState;
+
export const addInfoToast = addInfoToastAction;
export const addSuccessToast = addSuccessToastAction;
export const addDangerToast = addDangerToastAction;
@@ -269,10 +277,8 @@ const fieldConverter =
export const convertQueryToServer = fieldConverter(queryServerMapping);
export const convertQueryToClient = fieldConverter(queryClientMapping);
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getUpToDateQuery(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- rootState: any,
+ rootState: SqlLabRootState,
queryEditor: Partial<QueryEditor>,
key?: string,
): QueryEditor {
@@ -287,23 +293,23 @@ export function getUpToDateQuery(
} as QueryEditor;
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function resetState(data?: Record<string, unknown>): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any, getState: any) => {
+export function resetState(data?: Record<string, unknown>): SqlLabThunkAction {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { common } = getState();
const initialState = getInitialState({
...getBootstrapData(),
common,
- ...data,
+ ...(data as Partial<BootstrapData>),
});
dispatch({
type: RESET_STATE,
- sqlLabInitialState: initialState.sqlLab,
+ sqlLabInitialState: initialState.sqlLab as SqlLabRootState['sqlLab'],
});
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- rehydratePersistedState(dispatch, initialState as any);
+ rehydratePersistedState(
+ dispatch,
+ initialState as unknown as SqlLabRootState,
+ );
};
}
@@ -317,10 +323,10 @@ export function setEditorTabLastUpdate(timestamp: number): SqlLabAction {
return { type: SET_EDITOR_TAB_LAST_UPDATE, timestamp };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function scheduleQuery(query: Record<string, unknown>): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any) =>
+export function scheduleQuery(
+ query: Record<string, unknown>,
+): SqlLabThunkAction<Promise<unknown>> {
+ return (dispatch: AppDispatch) =>
SupersetClient.post({
endpoint: '/api/v1/saved_query/',
jsonPayload: query,
@@ -340,10 +346,10 @@ export function scheduleQuery(query: Record<string, unknown>): any {
);
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function estimateQueryCost(queryEditor: QueryEditor): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any, getState: any) => {
+export function estimateQueryCost(
+ queryEditor: QueryEditor,
+): SqlLabThunkAction<Promise<unknown[]>> {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { dbId, catalog, schema, sql, selectedText, templateParams } =
getUpToDateQuery(getState(), queryEditor);
const requestSql = selectedText || sql;
@@ -465,14 +471,12 @@ export function requestQueryResults(query: Query): SqlLabAction {
return { type: REQUEST_QUERY_RESULTS, query };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function fetchQueryResults(
query: Query,
displayLimit?: number,
timeoutInMs?: number,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const { SQLLAB_QUERY_RESULT_TIMEOUT } = getState().common?.conf ?? {};
dispatch(requestQueryResults(query));
@@ -487,9 +491,9 @@ export function fetchQueryResults(
parseMethod: 'json-bigint',
...(timeout && { timeout, signal: controller.signal }),
})
- .then(({ json }) =>
- dispatch(querySuccess(query, json as SqlExecuteResponse)),
- )
+ .then(({ json }) => {
+ dispatch(querySuccess(query, json as SqlExecuteResponse));
+ })
.catch(response => {
controller.abort();
getClientErrorObject(response).then(error => {
@@ -506,10 +510,11 @@ export function fetchQueryResults(
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function runQuery(query: Query, runPreviewOnly?: boolean): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function runQuery(
+ query: Query,
+ runPreviewOnly?: boolean,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
dispatch(startQuery(query, runPreviewOnly));
const postPayload = {
client_id: query.id,
@@ -556,7 +561,6 @@ export function runQuery(query: Query, runPreviewOnly?: boolean): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function runQueryFromSqlEditor(
database: Database | null,
queryEditor: QueryEditor,
@@ -564,9 +568,8 @@ export function runQueryFromSqlEditor(
tempTable?: string,
ctas?: boolean,
ctasMethod?: string,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+): SqlLabThunkAction {
+ return function (dispatch: AppDispatch, getState: GetState) {
const qe = getUpToDateQuery(getState(), queryEditor, queryEditor.id);
const query: Query = {
id: nanoid(11),
@@ -589,19 +592,17 @@ export function runQueryFromSqlEditor(
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function reRunQuery(query: Query): any {
+export function reRunQuery(query: Query): SqlLabThunkAction {
// run Query with a new id
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+ return function (dispatch: AppDispatch) {
dispatch(runQuery({ ...query, id: nanoid(11) }));
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function postStopQuery(query: Query): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function postStopQuery(
+ query: Query,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
return SupersetClient.post({
endpoint: '/api/v1/query/stop',
body: JSON.stringify({ client_id: query.id }),
@@ -620,10 +621,8 @@ export function setDatabases(databases: Database[]): SqlLabAction {
function migrateTable(
table: Table,
queryEditorId: string,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- dispatch: any,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
-): Promise<any> {
+ dispatch: AppDispatch,
+): Promise<unknown> {
return SupersetClient.post({
endpoint: encodeURI('/tableschemaview/'),
postPayload: { table: { ...table, queryEditorId } },
@@ -651,10 +650,8 @@ function migrateTable(
function migrateQuery(
queryId: string,
queryEditorId: string,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- dispatch: any,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
-): Promise<any> {
+ dispatch: AppDispatch,
+): Promise<unknown> {
return SupersetClient.post({
endpoint: encodeURI(`/tabstateview/${queryEditorId}/migrate_query`),
postPayload: { queryId },
@@ -681,18 +678,17 @@ function migrateQuery(
* stored in local storage will also be synchronized to the backend
* through syncQueryEditor.
*/
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function syncQueryEditor(queryEditor: QueryEditor): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+export function syncQueryEditor(
+ queryEditor: QueryEditor,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const { tables, queries } = getState().sqlLab;
const localStorageTables = tables.filter(
(table: Table) =>
table.inLocalStorage && table.queryEditorId === queryEditor.id,
);
const localStorageQueries = Object.values(queries).filter(
- (query: Query) =>
- query.inLocalStorage && query.sqlEditorId === queryEditor.id,
+ query => query.inLocalStorage && query.sqlEditorId === queryEditor.id,
);
return SupersetClient.post({
endpoint: '/tabstateview/',
@@ -748,20 +744,18 @@ export function addQueryEditor(
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function addNewQueryEditor(): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+export function addNewQueryEditor(): SqlLabThunkAction<SqlLabAction> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const {
sqlLab: { queryEditors, tabHistory, unsavedQueryEditor, databases },
common,
} = getState();
- const defaultDbId = common.conf.SQLLAB_DEFAULT_DBID;
+ const defaultDbId = common.conf.SQLLAB_DEFAULT_DBID as number | undefined;
const activeQueryEditor = queryEditors.find(
(qe: QueryEditor) => qe.id === tabHistory[tabHistory.length - 1],
);
const dbIds = Object.values(databases).map(
- (database: Database) => database.id,
+ (database: { id: number }) => database.id,
);
const firstDbId = dbIds.length > 0 ? Math.min(...dbIds) : undefined;
const { dbId, catalog, schema, queryLimit, autorun } = {
@@ -797,16 +791,16 @@ export function addNewQueryEditor(): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function cloneQueryToNewTab(query: Query, autorun: boolean): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+export function cloneQueryToNewTab(
+ query: Query,
+ autorun: boolean,
+): SqlLabThunkAction<SqlLabAction> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const state = getState();
const { queryEditors, unsavedQueryEditor, tabHistory } = state.sqlLab;
const sourceQueryEditor = {
...queryEditors.find(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (qe: any) => qe.id === tabHistory[tabHistory.length - 1],
+ (qe: QueryEditor) => qe.id === tabHistory[tabHistory.length - 1],
),
...(tabHistory[tabHistory.length - 1] === unsavedQueryEditor.id &&
unsavedQueryEditor),
@@ -819,7 +813,6 @@ export function cloneQueryToNewTab(query: Query, autorun: boolean): any {
autorun,
sql: query.sql,
queryLimit: sourceQueryEditor.queryLimit,
- maxRow: sourceQueryEditor.maxRow,
templateParams: sourceQueryEditor.templateParams,
};
return dispatch(addQueryEditor(queryEditor));
@@ -840,16 +833,13 @@ export function setActiveQueryEditor(queryEditor: QueryEditor): SqlLabAction {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function switchQueryEditor(goBackward = false): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+export function switchQueryEditor(goBackward = false): SqlLabThunkAction {
+ return function (dispatch: AppDispatch, getState: GetState) {
const { sqlLab } = getState();
const { queryEditors, tabHistory } = sqlLab;
const qeid = tabHistory[tabHistory.length - 1];
const currentIndex = queryEditors.findIndex(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (qe: any) => qe.id === qeid,
+ (qe: QueryEditor) => qe.id === qeid,
);
const nextIndex = goBackward
? currentIndex - 1 + queryEditors.length
@@ -915,13 +905,11 @@ export function setTables(tableSchemas: TableSchema[]): SqlLabAction {
return { type: SET_TABLES, tables };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function fetchQueryEditor(
queryEditor: QueryEditor,
displayLimit: number,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+): SqlLabThunkAction {
+ return function (dispatch: AppDispatch) {
const queryEditorId = queryEditor.tabViewId ?? queryEditor.id;
SupersetClient.get({
endpoint: encodeURI(`/tabstateview/${queryEditorId}`),
@@ -981,13 +969,12 @@ export function removeQueryEditor(queryEditor: QueryEditor): SqlLabAction {
return { type: REMOVE_QUERY_EDITOR, queryEditor };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function removeAllOtherQueryEditors(queryEditor: QueryEditor): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+export function removeAllOtherQueryEditors(
+ queryEditor: QueryEditor,
+): SqlLabThunkAction {
+ return function (dispatch: AppDispatch, getState: GetState) {
const { sqlLab } = getState();
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- sqlLab.queryEditors?.forEach((otherQueryEditor: any) => {
+ sqlLab.queryEditors?.forEach((otherQueryEditor: QueryEditor) => {
if (otherQueryEditor.id !== queryEditor.id) {
dispatch(removeQueryEditor(otherQueryEditor));
}
@@ -995,10 +982,8 @@ export function removeAllOtherQueryEditors(queryEditor: QueryEditor): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function removeQuery(query: Query): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function removeQuery(query: Query): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
const queryEditorId = query.sqlEditorId ?? query.id;
const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
? SupersetClient.delete({
@@ -1070,16 +1055,15 @@ export function queryEditorSetTitle(
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function saveQuery(query: Partial<QueryEditor>, clientId: string): any {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
+export function saveQuery(
+ query: Partial<QueryEditor>,
+ clientId: string,
+): SqlLabThunkAction<Promise<Record<string, unknown> | void>> {
const { id: _id, ...payload } = convertQueryToServer(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- query as any,
+ query as Record<string, unknown>,
);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any) =>
+ return (dispatch: AppDispatch) =>
SupersetClient.post({
endpoint: '/api/v1/saved_query/',
jsonPayload: convertQueryToServer(payload as Record<string, unknown>),
@@ -1103,42 +1087,38 @@ export function saveQuery(query: Partial<QueryEditor>, clientId: string): any {
);
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const addSavedQueryToTabState =
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (queryEditor: QueryEditor, savedQuery: { remoteId: string }): any =>
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (dispatch: any) => {
- const queryEditorId = queryEditor.tabViewId ?? queryEditor.id;
- const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
- ? SupersetClient.put({
- endpoint: `/tabstateview/${queryEditorId}`,
- postPayload: { saved_query_id: savedQuery.remoteId },
- })
- : Promise.resolve();
-
- return sync
- .catch(() => {
- dispatch(addDangerToast(t('Your query was not properly saved')));
+ (
+ queryEditor: QueryEditor,
+ savedQuery: { remoteId: string },
+ ): SqlLabThunkAction<Promise<unknown>> =>
+ (dispatch: AppDispatch) => {
+ const queryEditorId = queryEditor.tabViewId ?? queryEditor.id;
+ const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
+ ? SupersetClient.put({
+ endpoint: `/tabstateview/${queryEditorId}`,
+ postPayload: { saved_query_id: savedQuery.remoteId },
})
- .then(() => {
- dispatch(addSuccessToast(t('Your query was saved')));
- });
- };
+ : Promise.resolve();
+
+ return sync
+ .catch(() => {
+ dispatch(addDangerToast(t('Your query was not properly saved')));
+ })
+ .then(() => {
+ dispatch(addSuccessToast(t('Your query was saved')));
+ });
+ };
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function updateSavedQuery(
query: Partial<QueryEditor>,
clientId: string,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
+): SqlLabThunkAction<Promise<unknown>> {
const { id: _id, ...payload } = convertQueryToServer(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- query as any,
+ query as Record<string, unknown>,
);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any) =>
+ return (dispatch: AppDispatch) =>
SupersetClient.put({
endpoint: `/api/v1/saved_query/${query.remoteId}`,
jsonPayload: convertQueryToServer(payload as Record<string, unknown>),
@@ -1153,7 +1133,9 @@ export function updateSavedQuery(
console.error(message, e);
dispatch(addDangerToast(message));
})
- .then(() => dispatch(updateQueryEditor(query)));
+ .then(() => {
+ dispatch(updateQueryEditor(query));
+ });
}
export function queryEditorSetSql(
@@ -1171,14 +1153,12 @@ export function queryEditorSetCursorPosition(
return { type: QUERY_EDITOR_SET_CURSOR_POSITION, queryEditor, position };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function queryEditorSetAndSaveSql(
targetQueryEditor: Partial<QueryEditor>,
sql: string,
queryId?: string,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const queryEditor = getUpToDateQuery(getState(), targetQueryEditor);
// saved query and set tab state use this action
dispatch(queryEditorSetSql(queryEditor, sql, queryId));
@@ -1203,10 +1183,10 @@ export function queryEditorSetAndSaveSql(
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function formatQuery(queryEditor: QueryEditor): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+export function formatQuery(
+ queryEditor: QueryEditor,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const { sql, dbId, templateParams } = getUpToDateQuery(
getState(),
queryEditor,
@@ -1276,16 +1256,14 @@ export function mergeTable(
return { type: MERGE_TABLE, table, query, prepend };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function addTable(
queryEditor: Partial<QueryEditor>,
tableName: string,
catalogName: string | null,
schemaName: string,
expanded = true,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+): SqlLabThunkAction {
+ return function (dispatch: AppDispatch, getState: GetState) {
const { dbId } = getUpToDateQuery(getState(), queryEditor, queryEditor.id);
const table = {
dbId,
@@ -1315,13 +1293,11 @@ interface NewTable {
previewQueryId?: string;
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function runTablePreviewQuery(
newTable: NewTable,
runPreviewOnly?: boolean,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any, getState: any) {
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch, getState: GetState) {
const {
sqlLab: { databases },
} = getState();
@@ -1375,14 +1351,12 @@ interface TableMetaData {
indexes?: unknown[];
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function syncTable(
table: Table,
tableMetadata: TableMetaData,
finalQueryEditorId?: string,
-): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
const finalTable = { ...table, queryEditorId: finalQueryEditorId };
const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
? SupersetClient.post({
@@ -1422,10 +1396,8 @@ export function changeDataPreviewId(
return { type: CHANGE_DATA_PREVIEW_ID, oldQueryId, newQuery };
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function reFetchQueryResults(query: Query): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function reFetchQueryResults(query: Query): SqlLabThunkAction {
+ return function (dispatch: AppDispatch) {
const newQuery: Query = {
id: nanoid(),
dbId: query.dbId,
@@ -1443,10 +1415,8 @@ export function reFetchQueryResults(query: Query): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function expandTable(table: Table): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function expandTable(table: Table): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
const sync =
isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) &&
table.initialized
@@ -1471,10 +1441,10 @@ export function expandTable(table: Table): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function collapseTable(table: Table): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function collapseTable(
+ table: Table,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
const sync =
isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) &&
table.initialized
@@ -1499,10 +1469,10 @@ export function collapseTable(table: Table): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function removeTables(tables: Table[]): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function removeTables(
+ tables: Table[],
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
const tablesToRemove = tables?.filter(Boolean) ?? [];
const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
? Promise.all(
@@ -1554,10 +1524,8 @@ export function persistEditorHeight(
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function popPermalink(key: string): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function popPermalink(key: string): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
return SupersetClient.get({ endpoint: `/api/v1/sqllab/permalink/${key}` })
.then(({ json }) =>
dispatch(
@@ -1576,10 +1544,10 @@ export function popPermalink(key: string): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function popStoredQuery(urlId: string): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function popStoredQuery(
+ urlId: string,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
return SupersetClient.get({
endpoint: `/api/v1/sqllab/permalink/kv:${urlId}`,
})
@@ -1599,10 +1567,10 @@ export function popStoredQuery(urlId: string): any {
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function popSavedQuery(saveQueryId: string): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function popSavedQuery(
+ saveQueryId: string,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
return SupersetClient.get({
endpoint: `/api/v1/saved_query/${saveQueryId}`,
})
@@ -1626,10 +1594,8 @@ export function popSavedQuery(saveQueryId: string): any {
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function popQuery(queryId: string): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function popQuery(queryId: string): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
return SupersetClient.get({
endpoint: `/api/v1/query/${queryId}`,
})
@@ -1648,10 +1614,11 @@ export function popQuery(queryId: string): any {
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function popDatasourceQuery(datasourceKey: string, sql?: string): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return function (dispatch: any) {
+export function popDatasourceQuery(
+ datasourceKey: string,
+ sql?: string,
+): SqlLabThunkAction<Promise<unknown>> {
+ return function (dispatch: AppDispatch) {
const QUERY_TEXT = t('Query');
const datasetId = datasourceKey.split('__')[0];
@@ -1699,10 +1666,10 @@ interface VizOptions {
templateParams?: string;
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function createDatasource(vizOptions: VizOptions): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any) => {
+export function createDatasource(
+ vizOptions: VizOptions,
+): SqlLabThunkAction<Promise<unknown>> {
+ return (dispatch: AppDispatch) => {
dispatch(createDatasourceStarted());
const { dbId, catalog, schema, datasourceName, sql, templateParams } =
vizOptions;
@@ -1740,10 +1707,10 @@ export function createDatasource(vizOptions: VizOptions): any {
};
}
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export function createCtasDatasource(vizOptions: Record<string, unknown>): any {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return (dispatch: any) => {
+export function createCtasDatasource(
+ vizOptions: Record<string, unknown>,
+): SqlLabThunkAction<Promise<{ id: number }>> {
+ return (dispatch: AppDispatch) => {
dispatch(createDatasourceStarted());
return SupersetClient.post({
endpoint: '/api/v1/dataset/get_or_create/',
diff --git a/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.test.ts b/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.test.ts
index e54322cca18..9aa7dcdacfd 100644
--- a/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.test.ts
+++ b/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.test.ts
@@ -230,14 +230,14 @@ test('returns column keywords among selected tables', async () => {
},
),
);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
storeWithSqlLab.dispatch(
addTable(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
{ id: expectQueryEditorId } as any,
expectTable,
expectCatalog,
expectSchema,
- ),
+ ) as any,
);
});
@@ -275,14 +275,14 @@ test('returns column keywords among selected tables', async () => {
);
act(() => {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
storeWithSqlLab.dispatch(
addTable(
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
{ id: expectQueryEditorId } as any,
unexpectedTable,
expectCatalog,
expectSchema,
- ),
+ ) as any,
);
});
diff --git a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx
index d0436115325..0439157b055 100644
--- a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx
@@ -72,13 +72,13 @@ describe('QueryAutoRefresh', () => {
});
test('isQueryRunning returns false for invalid query', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(isQueryRunning(null)).toBe(false);
- // @ts-ignore
+ // @ts-expect-error
expect(isQueryRunning(undefined)).toBe(false);
- // @ts-ignore
+ // @ts-expect-error
expect(isQueryRunning('I Should Be An Object')).toBe(false);
- // @ts-ignore
+ // @ts-expect-error
expect(isQueryRunning({ state: { badFormat: true } })).toBe(false);
});
@@ -91,20 +91,19 @@ describe('QueryAutoRefresh', () => {
});
test('shouldCheckForQueries is false for invalid inputs', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(shouldCheckForQueries(null)).toBe(false);
- // @ts-ignore
+ // @ts-expect-error
expect(shouldCheckForQueries(undefined)).toBe(false);
expect(
- // @ts-ignore
shouldCheckForQueries({
- // @ts-ignore
+ // @ts-expect-error
'1234': null,
- // @ts-ignore
+ // @ts-expect-error
'23425': 'hello world',
- // @ts-ignore
+ // @ts-expect-error
'345': [],
- // @ts-ignore
+ // @ts-expect-error
'57346': undefined,
}),
).toBe(false);
@@ -174,7 +173,7 @@ describe('QueryAutoRefresh', () => {
render(
<QueryAutoRefresh
- // @ts-ignore
+ // @ts-expect-error
queries={{ ...runningQueries, g324t: null }}
queriesLastUpdate={queriesLastUpdate}
/>,
diff --git a/superset-frontend/src/SqlLab/components/ResultSet/ResultSet.test.tsx b/superset-frontend/src/SqlLab/components/ResultSet/ResultSet.test.tsx
index be5a1e22fc3..20871fc029f 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet/ResultSet.test.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet/ResultSet.test.tsx
@@ -286,7 +286,6 @@ describe('ResultSet', () => {
store,
);
- // @ts-ignore
rerender(<ResultSet {...mockedProps} {...newProps} />);
expect(store.getActions()).toHaveLength(1);
expect(store.getActions()[0].query.results).toEqual(cachedQuery.results);
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
index 29531a652e4..7998d591388 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
@@ -263,7 +263,7 @@ describe('SaveDatasetModal', () => {
});
test('renders a checkbox button when template processing is enabled', () => {
- // @ts-ignore
+ // @ts-expect-error
global.featureFlags = {
[FeatureFlag.EnableTemplateProcessing]: true,
};
@@ -272,7 +272,7 @@ describe('SaveDatasetModal', () => {
});
test('correctly includes template parameters when template processing is enabled', () => {
- // @ts-ignore
+ // @ts-expect-error
global.featureFlags = {
[FeatureFlag.EnableTemplateProcessing]: true,
};
@@ -307,7 +307,7 @@ describe('SaveDatasetModal', () => {
});
test('correctly excludes template parameters when template processing is enabled', () => {
- // @ts-ignore
+ // @ts-expect-error
global.featureFlags = {
[FeatureFlag.EnableTemplateProcessing]: true,
};
diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
index 18262329970..e1483e6663b 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
@@ -787,7 +787,12 @@ const SqlEditor: FC<Props> = ({
const onSaveQuery = async (query: QueryPayload, clientId: string) => {
const savedQuery = await dispatch(saveQuery(query, clientId));
- dispatch(addSavedQueryToTabState(queryEditor, savedQuery));
+ dispatch(
+ addSavedQueryToTabState(
+ queryEditor,
+ savedQuery as unknown as { remoteId: string },
+ ),
+ );
};
const renderEditorPrimaryAction = () => {
diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.ts b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
index d614622dfff..d11d32eb751 100644
--- a/superset-frontend/src/SqlLab/reducers/getInitialState.ts
+++ b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
@@ -254,7 +254,9 @@ export default function getInitialState({
activeSouthPaneTab: 'Results',
alerts: [],
databases,
+ dbConnect: false,
offline: false,
+ errorMessage: null,
queries: Object.fromEntries(
Object.entries(queries).map(([queryId, query]) => [
queryId,
diff --git a/superset-frontend/src/chartCustomizations/components/TimeColumn/TimeColumnFilterPlugin.tsx b/superset-frontend/src/chartCustomizations/components/TimeColumn/TimeColumnFilterPlugin.tsx
index 6faf49f1171..7377816429e 100644
--- a/superset-frontend/src/chartCustomizations/components/TimeColumn/TimeColumnFilterPlugin.tsx
+++ b/superset-frontend/src/chartCustomizations/components/TimeColumn/TimeColumnFilterPlugin.tsx
@@ -111,7 +111,7 @@ export default function PluginFilterTimeColumn(
allowClear
value={value}
placeholder={placeholderText}
- // @ts-ignore
+ // @ts-expect-error
onChange={handleChange}
onBlur={unsetFocusedFilter}
onFocus={setFocusedFilter}
diff --git a/superset-frontend/src/components/Chart/ChartContextMenu/useContextMenu.test.tsx b/superset-frontend/src/components/Chart/ChartContextMenu/useContextMenu.test.tsx
index 416d15a01f8..a447414b904 100644
--- a/superset-frontend/src/components/Chart/ChartContextMenu/useContextMenu.test.tsx
+++ b/superset-frontend/src/components/Chart/ChartContextMenu/useContextMenu.test.tsx
@@ -33,7 +33,7 @@ const mockCachedSupersetGet = cachedSupersetGet as jest.MockedFunction<
>;
const CONTEXT_MENU_TEST_ID = 'chart-context-menu';
-// @ts-ignore
+// @ts-expect-error
global.featureFlags = {
[FeatureFlag.DrillToDetail]: true,
[FeatureFlag.DrillBy]: true,
diff --git a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
index d09337c72ee..64cc312c9ac 100644
--- a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
@@ -162,7 +162,7 @@ test('should NOT render see more button when show_issue_info is false', () => {
});
test('should render message when wrong value provided for custom_doc_urls', () => {
- // @ts-ignore
+ // @ts-expect-error
render(<DatabaseErrorMessage {...mockedPropsWithCustomErrorAndBadLinks} />, {
useRedux: true,
});
diff --git a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
index b969caa3446..dc562e473ba 100644
--- a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
@@ -55,7 +55,7 @@ export function ErrorMessageWithStackTrace({
// Check if a custom error message component was registered for this message
if (error) {
const ErrorMessageComponent = getErrorMessageComponentRegistry().get(
- // @ts-ignore: plan to modify this part so that all errors in Superset 6.0 are standardized as Superset API error types
+ // @ts-expect-error: plan to modify this part so that all errors in Superset 6.0 are standardized as Superset API error types
error.errorType ?? error.error_type,
);
if (ErrorMessageComponent) {
diff --git a/superset-frontend/src/components/ListView/ListView.test.tsx b/superset-frontend/src/components/ListView/ListView.test.tsx
index 6434b11839f..ed4e0fc7f01 100644
--- a/superset-frontend/src/components/ListView/ListView.test.tsx
+++ b/superset-frontend/src/components/ListView/ListView.test.tsx
@@ -19,6 +19,7 @@
import { render, screen, within, waitFor } from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import { ReactNode } from 'react';
@@ -51,16 +52,6 @@ type MockedListViewProps = Omit<
const middlewares = [thunk];
const mockStore = configureStore(middlewares);
-function makeMockLocation(query?: string) {
- const queryStr = query ? encodeURIComponent(query) : '';
- return {
- protocol: 'http:',
- host: 'localhost',
- pathname: '/',
- search: queryStr.length ? `?${queryStr}` : '',
- } as Location;
-}
-
const fetchSelectsMock = jest.fn(() =>
Promise.resolve({ data: [], totalCount: 0 }),
);
@@ -214,7 +205,7 @@ test('redirects to first page when page index is invalid', async () => {
const factory = (overrides?: Partial<ListViewProps>) => {
const props = { ...mockedPropsComprehensive, ...overrides };
return render(
- <QueryParamProvider location={makeMockLocation()}>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<ListView {...props} />
</QueryParamProvider>,
{ store: mockStore() },
diff --git a/superset-frontend/src/dashboard/actions/dashboardLayout.ts b/superset-frontend/src/dashboard/actions/dashboardLayout.ts
index fad59692fa7..8ef0f61548c 100644
--- a/superset-frontend/src/dashboard/actions/dashboardLayout.ts
+++ b/superset-frontend/src/dashboard/actions/dashboardLayout.ts
@@ -18,7 +18,8 @@
*/
import { ActionCreators as UndoActionCreators } from 'redux-undo';
import { t } from '@apache-superset/core/ui';
-import { AnyAction, Dispatch } from 'redux';
+import type { AnyAction } from 'redux';
+import type { ThunkDispatch } from 'redux-thunk';
import { addWarningToast } from 'src/components/MessageToasts/actions';
import { TABS_TYPE, ROW_TYPE } from 'src/dashboard/util/componentTypes';
import {
@@ -35,6 +36,7 @@ import { updateLayoutComponents } from './dashboardFilters';
import { setUnsavedChanges } from './dashboardState';
type GetState = () => RootState;
+type AppDispatch = ThunkDispatch<RootState, undefined, AnyAction>;
// Component CRUD -------------------------------------------------------------
export const UPDATE_COMPONENTS = 'UPDATE_COMPONENTS';
@@ -103,22 +105,11 @@ function setUnsavedChangesAfterAction<
action: T,
): (
...args: Parameters<T>
-) => (dispatch: Dispatch, getState: GetState) => void {
+) => (dispatch: AppDispatch, getState: GetState) => void {
return (...args: Parameters<T>) =>
- (dispatch: Dispatch, getState: GetState) => {
+ (dispatch: AppDispatch, getState: GetState) => {
const result = action(...args);
- if (typeof result === 'function') {
- dispatch(
- (
- result as unknown as (
- dispatch: Dispatch,
- getState: GetState,
- ) => AnyAction
- )(dispatch, getState),
- );
- } else {
- dispatch(result);
- }
+ dispatch(result);
const { dashboardLayout, dashboardState } = getState();
@@ -128,7 +119,7 @@ function setUnsavedChangesAfterAction<
// trigger dashboardFilters state update if dashboard layout is changed.
if (!isComponentLevelEvent) {
const components = dashboardLayout.present;
- dispatch(updateLayoutComponents(components) as unknown as AnyAction);
+ dispatch(updateLayoutComponents(components));
}
if (!dashboardState.hasUnsavedChanges) {
@@ -150,8 +141,8 @@ export const updateComponents = setUnsavedChangesAfterAction(
export function updateDashboardTitle(
text: string,
-): (dispatch: Dispatch, getState: GetState) => void {
- return (dispatch: Dispatch, getState: GetState) => {
+): (dispatch: AppDispatch, getState: GetState) => void {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { dashboardLayout } = getState();
dispatch(
updateComponents({
@@ -162,7 +153,7 @@ export function updateDashboardTitle(
text,
},
},
- }) as unknown as AnyAction,
+ }),
);
};
}
@@ -232,8 +223,8 @@ export function resizeComponent({
id,
width,
height,
-}: ResizeComponentParams): (dispatch: Dispatch, getState: GetState) => void {
- return (dispatch: Dispatch, getState: GetState) => {
+}: ResizeComponentParams): (dispatch: AppDispatch, getState: GetState) => void {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { dashboardLayout: undoableLayout } = getState();
const { present: dashboard } = undoableLayout;
const component = dashboard[id];
@@ -252,7 +243,7 @@ export function resizeComponent({
},
};
- dispatch(updateComponents(updatedComponents) as unknown as AnyAction);
+ dispatch(updateComponents(updatedComponents));
}
};
}
@@ -270,7 +261,10 @@ const moveComponent = setUnsavedChangesAfterAction(
export const HANDLE_COMPONENT_DROP = 'HANDLE_COMPONENT_DROP';
export function handleComponentDrop(dropResult: DropResult) {
- return (dispatch: Dispatch, getState: GetState): null | AnyAction | void => {
+ return (
+ dispatch: AppDispatch,
+ getState: GetState,
+ ): null | AnyAction | void => {
const overflowsParent = dropOverflowsParent(
dropResult,
getState().dashboardLayout.present,
@@ -295,9 +289,9 @@ export function handleComponentDrop(dropResult: DropResult) {
: '';
if (droppedOnRoot) {
- dispatch(createTopLevelTabs(dropResult) as unknown as AnyAction);
+ dispatch(createTopLevelTabs(dropResult));
} else if (destination && isNewComponent) {
- dispatch(createComponent(dropResult) as unknown as AnyAction);
+ dispatch(createComponent(dropResult));
} else if (
// Add additional allow-to-drop logic for tag/tags source.
// We only allow
@@ -322,7 +316,7 @@ export function handleComponentDrop(dropResult: DropResult) {
(destination.id === source.id && destination.index === source.index)
)
) {
- dispatch(moveComponent(dropResult) as unknown as AnyAction);
+ dispatch(moveComponent(dropResult));
}
// call getState() again down here in case redux state is stale after
@@ -345,7 +339,7 @@ export function handleComponentDrop(dropResult: DropResult) {
childId: source.id,
layout,
});
- dispatch(deleteComponent(source.id, parentId) as unknown as AnyAction);
+ dispatch(deleteComponent(source.id, parentId));
}
// show warning if item has been moved between different scope
@@ -376,10 +370,10 @@ export const clearDashboardHistory = (): AnyAction =>
// Undo redo ------------------------------------------------------------------
export function undoLayoutAction(): (
- dispatch: Dispatch,
+ dispatch: AppDispatch,
getState: GetState,
) => void {
- return (dispatch: Dispatch, getState: GetState) => {
+ return (dispatch: AppDispatch, getState: GetState) => {
dispatch(UndoActionCreators.undo());
const { dashboardLayout, dashboardState } = getState();
diff --git a/superset-frontend/src/dashboard/actions/dashboardState.ts b/superset-frontend/src/dashboard/actions/dashboardState.ts
index c6c6a5d71e9..ea8ba23b9b0 100644
--- a/superset-frontend/src/dashboard/actions/dashboardState.ts
+++ b/superset-frontend/src/dashboard/actions/dashboardState.ts
@@ -60,7 +60,8 @@ import { logEvent } from 'src/logger/actions';
import { LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA } from 'src/logger/LogUtils';
import { isEqual } from 'lodash';
import { navigateWithState, navigateTo } from 'src/utils/navigationUtils';
-import { AnyAction, Dispatch } from 'redux';
+import type { AnyAction } from 'redux';
+import type { ThunkDispatch } from 'redux-thunk';
import { ResourceStatus } from 'src/hooks/apiResources/apiResources';
import type { AgGridChartState } from '@superset-ui/core';
import type { DashboardChartStates } from 'src/dashboard/types/chartState';
@@ -88,6 +89,15 @@ import type { DashboardState, RootState, Slice } from '../types';
type GetState = () => RootState;
+// Dashboard dispatch type. The base ThunkDispatch handles dashboard-specific
+// thunks. The intersection with a generic function-accepting overload allows
+// dispatching thunks from other modules (e.g. chart actions) whose RootState
+// type differs from the dashboard RootState. At runtime the Redux store
+// satisfies all module state shapes.
+interface AppDispatch extends ThunkDispatch<RootState, undefined, AnyAction> {
+ <R>(asyncAction: (...args: never[]) => R): R;
+}
+
// ---------------------------------------------------------------------------
// Simple action creators
// ---------------------------------------------------------------------------
@@ -152,7 +162,7 @@ export function toggleFaveStar(isStarred: boolean): ToggleFaveStarAction {
}
export function fetchFaveStar(id: number) {
- return function fetchFaveStarThunk(dispatch: Dispatch) {
+ return function fetchFaveStarThunk(dispatch: AppDispatch) {
return SupersetClient.get({
endpoint: `/api/v1/dashboard/favorite_status/?q=${rison.encode([id])}`,
})
@@ -172,7 +182,7 @@ export function fetchFaveStar(id: number) {
}
export function saveFaveStar(id: number, isStarred: boolean) {
- return function saveFaveStarThunk(dispatch: Dispatch) {
+ return function saveFaveStarThunk(dispatch: AppDispatch) {
const endpoint = `/api/v1/dashboard/${id}/favorites/`;
const apiCall = isStarred
? SupersetClient.delete({
@@ -206,8 +216,8 @@ export function togglePublished(isPublished: boolean): TogglePublishedAction {
export function savePublished(
id: number,
isPublished: boolean,
-): (dispatch: Dispatch) => Promise<void> {
- return function savePublishedThunk(dispatch: Dispatch): Promise<void> {
+): (dispatch: AppDispatch) => Promise<void> {
+ return function savePublishedThunk(dispatch: AppDispatch): Promise<void> {
return SupersetClient.put({
endpoint: `/api/v1/dashboard/${id}`,
headers: { 'Content-Type': 'application/json' },
@@ -295,8 +305,8 @@ export function setRefreshFrequency(
export function saveDashboardRequestSuccess(
lastModifiedTime: number,
-): (dispatch: Dispatch) => void {
- return (dispatch: Dispatch) => {
+): (dispatch: AppDispatch) => void {
+ return (dispatch: AppDispatch) => {
dispatch(onSave(lastModifiedTime));
// clear layout undo history
dispatch(UndoActionCreators.clearHistory());
@@ -382,7 +392,7 @@ export function setDashboardSharedLabelsColorsSynced(): SetDashboardSharedLabels
export const setDashboardMetadata =
(updatedMetadata: JsonObject) =>
- async (dispatch: Dispatch, getState: GetState): Promise<void> => {
+ async (dispatch: AppDispatch, getState: GetState): Promise<void> => {
const { dashboardInfo } = getState();
dispatch(
dashboardInfoChanged({
@@ -417,8 +427,8 @@ export function saveDashboardRequest(
data: DashboardSaveData,
id: number,
saveType: string,
-): (dispatch: Dispatch, getState: GetState) => Promise<JsonObject | void> {
- return (dispatch: Dispatch, getState: GetState) => {
+): (dispatch: AppDispatch, getState: GetState) => Promise<JsonObject | void> {
+ return (dispatch: AppDispatch, getState: GetState) => {
dispatch({ type: UPDATE_COMPONENTS_PARENTS_LIST });
dispatch(saveDashboardStarted());
@@ -431,12 +441,7 @@ export function saveDashboardRequest(
.pop() as string;
const directPathToFilter = (layout[componentId]?.parents || []).slice();
directPathToFilter.push(componentId);
- dispatch(
- updateDirectPathToFilter(
- chartId as number,
- directPathToFilter,
- ) as unknown as AnyAction,
- );
+ dispatch(updateDirectPathToFilter(chartId as number, directPathToFilter));
});
// serialize selected values for each filter field, grouped by filter id
const serializedFilters = serializeActiveFilterValues(getActiveFilters());
@@ -524,9 +529,7 @@ export function saveDashboardRequest(
const lastModifiedTime = (response.json as JsonObject).result
?.last_modified_time as number;
if (lastModifiedTime) {
- dispatch(
- saveDashboardRequestSuccess(lastModifiedTime) as unknown as AnyAction,
- );
+ dispatch(saveDashboardRequestSuccess(lastModifiedTime));
}
const { chartConfiguration, globalChartConfiguration } =
handleChartConfiguration();
@@ -534,7 +537,7 @@ export function saveDashboardRequest(
saveChartConfiguration({
chartConfiguration,
globalChartConfiguration,
- }) as unknown as AnyAction,
+ }),
);
dispatch(saveDashboardFinished());
navigateTo(
@@ -554,7 +557,7 @@ export function saveDashboardRequest(
const parsedMetadata: JsonObject = JSON.parse(
updatedDashboard.json_metadata as string,
);
- dispatch(setDashboardMetadata(parsedMetadata) as unknown as AnyAction);
+ dispatch(setDashboardMetadata(parsedMetadata));
if (parsedMetadata.chart_configuration) {
dispatch({
type: SAVE_CHART_CONFIG_COMPLETE,
@@ -579,7 +582,7 @@ export function saveDashboardRequest(
dispatch(
setDatasources(
datasources as Parameters<typeof setDatasources>[0],
- ) as unknown as AnyAction,
+ ),
);
}
})
@@ -588,9 +591,7 @@ export function saveDashboardRequest(
});
}
if (lastModifiedTime) {
- dispatch(
- saveDashboardRequestSuccess(lastModifiedTime) as unknown as AnyAction,
- );
+ dispatch(saveDashboardRequestSuccess(lastModifiedTime));
}
dispatch(saveDashboardFinished());
// redirect to the new slug or id
@@ -701,7 +702,7 @@ export function saveDashboardRequest(
logEvent(LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA, {
dashboard_id: id,
items: overwriteConfirmItems,
- }) as unknown as AnyAction,
+ }),
);
dispatch(addDangerToast(errorText));
});
@@ -741,13 +742,11 @@ export function fetchCharts(
force = false,
interval = 0,
dashboardId?: number,
-): (dispatch: Dispatch, getState: GetState) => void {
- return (dispatch: Dispatch, getState: GetState) => {
+): (dispatch: AppDispatch, getState: GetState) => void {
+ return (dispatch: AppDispatch, getState: GetState) => {
if (!interval) {
chartList.forEach(chartKey =>
- dispatch(
- refreshChart(chartKey, force, dashboardId) as unknown as AnyAction,
- ),
+ dispatch(refreshChart(chartKey, force, dashboardId)),
);
return;
}
@@ -769,10 +768,7 @@ export function fetchCharts(
: 0;
chartList.forEach((chartKey: number, i: number) => {
setTimeout(
- () =>
- dispatch(
- refreshChart(chartKey, force, dashboardId) as unknown as AnyAction,
- ),
+ () => dispatch(refreshChart(chartKey, force, dashboardId)),
delay * i,
);
});
@@ -784,17 +780,10 @@ const refreshCharts = (
force: boolean,
interval: number,
dashboardId: number | undefined,
- dispatch: Dispatch,
+ dispatch: AppDispatch,
): Promise<void> =>
new Promise(resolve => {
- dispatch(
- fetchCharts(
- chartList,
- force,
- interval,
- dashboardId,
- ) as unknown as AnyAction,
- );
+ dispatch(fetchCharts(chartList, force, interval, dashboardId));
resolve();
});
@@ -836,8 +825,8 @@ export function onRefresh(
interval = 0,
dashboardId?: number,
isLazyLoad = false,
-): (dispatch: Dispatch) => void {
- return (dispatch: Dispatch) => {
+): (dispatch: AppDispatch) => void {
+ return (dispatch: AppDispatch) => {
// Only dispatch ON_REFRESH for dashboard-level refreshes
// Skip it for lazy-loaded tabs to prevent infinite loops
if (!isLazyLoad) {
@@ -871,8 +860,8 @@ export function showBuilderPane(): ShowBuilderPaneAction {
export function addSliceToDashboard(
id: number,
-): (dispatch: Dispatch, getState: GetState) => Promise<void> | AnyAction {
- return (dispatch: Dispatch, getState: GetState) => {
+): (dispatch: AppDispatch, getState: GetState) => Promise<void> | AnyAction {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { sliceEntities } = getState();
const selectedSlice = (sliceEntities.slices as Record<number, JsonObject>)[
id
@@ -897,24 +886,20 @@ export function addSliceToDashboard(
};
return Promise.all([
- dispatch(addChart(newChart, id) as unknown as AnyAction),
- dispatch(
- fetchDatasourceMetadata(
- form_data.datasource as string,
- ) as unknown as AnyAction,
- ),
+ dispatch(addChart(newChart, id)),
+ dispatch(fetchDatasourceMetadata(form_data.datasource as string)),
]).then(() => {
- dispatch(addSlice(selectedSlice as unknown as Slice));
+ dispatch(addSlice(selectedSlice as Slice));
});
};
}
export function removeSliceFromDashboard(
id: number,
-): (dispatch: Dispatch) => void {
- return (dispatch: Dispatch) => {
+): (dispatch: AppDispatch) => void {
+ return (dispatch: AppDispatch) => {
dispatch(removeSlice(id));
- dispatch(removeChart(id) as unknown as AnyAction);
+ dispatch(removeChart(id));
getLabelsColorMap().removeSlice(id);
};
}
@@ -1005,8 +990,8 @@ interface SetActiveTabAction {
export function setActiveTab(
tabId: string,
prevTabId?: string,
-): (dispatch: Dispatch, getState: GetState) => SetActiveTabAction {
- return (dispatch: Dispatch, getState: GetState) => {
+): (dispatch: AppDispatch, getState: GetState) => SetActiveTabAction {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { dashboardLayout, dashboardState } = getState();
const { activeTabs, inactiveTabs } = findTabsToRestore(
tabId,
@@ -1171,10 +1156,10 @@ export function setMaxUndoHistoryExceeded(
}
export function maxUndoHistoryToast(): (
- dispatch: Dispatch,
+ dispatch: AppDispatch,
getState: GetState,
) => AnyAction {
- return (dispatch: Dispatch, getState: GetState) => {
+ return (dispatch: AppDispatch, getState: GetState) => {
const { dashboardLayout } = getState();
const historyLength = dashboardLayout.past.length;
@@ -1239,7 +1224,7 @@ const storeDashboardColorConfig = async (
*/
export const persistDashboardLabelsColor =
() =>
- async (dispatch: Dispatch, getState: GetState): Promise<void> => {
+ async (dispatch: AppDispatch, getState: GetState): Promise<void> => {
const {
dashboardInfo: { id, metadata },
dashboardState: { labelsColorMapMustSync, sharedLabelsColorsMustSync },
@@ -1262,7 +1247,7 @@ export const persistDashboardLabelsColor =
*/
export const applyDashboardLabelsColorOnLoad =
(metadata: JsonObject) =>
- async (dispatch: Dispatch): Promise<void> => {
+ async (dispatch: AppDispatch): Promise<void> => {
try {
const customLabelsColor = (metadata.label_colors || {}) as Record<
string,
@@ -1280,7 +1265,7 @@ export const applyDashboardLabelsColorOnLoad =
dispatch(
setDashboardMetadata({
shared_label_colors: [],
- }) as unknown as AnyAction,
+ }),
);
}
// backward compatibility of map_label_colors
@@ -1305,7 +1290,7 @@ export const applyDashboardLabelsColorOnLoad =
dispatch(
setDashboardMetadata({
color_scheme: updatedScheme,
- }) as unknown as AnyAction,
+ }),
);
}
@@ -1321,7 +1306,7 @@ export const applyDashboardLabelsColorOnLoad =
dispatch(
setDashboardMetadata({
color_scheme_domain: freshColorSchemeDomain,
- }) as unknown as AnyAction,
+ }),
);
}
@@ -1335,7 +1320,7 @@ export const applyDashboardLabelsColorOnLoad =
dispatch(
setDashboardMetadata({
map_label_colors: getFreshLabelsColorMapEntries(customLabelsColor),
- }) as unknown as AnyAction,
+ }),
);
}
@@ -1356,7 +1341,7 @@ export const applyDashboardLabelsColorOnLoad =
*/
export const ensureSyncedLabelsColorMap =
(metadata: JsonObject) =>
- (dispatch: Dispatch, getState: GetState): void => {
+ (dispatch: AppDispatch, getState: GetState): void => {
const syncLabelsColorMap = (): void => {
const {
dashboardState: { labelsColorMapMustSync },
@@ -1381,7 +1366,7 @@ export const ensureSyncedLabelsColorMap =
dispatch(
setDashboardMetadata({
map_label_colors: freshColorMapEntries,
- }) as unknown as AnyAction,
+ }),
);
}
@@ -1403,7 +1388,7 @@ export const ensureSyncedLabelsColorMap =
*/
export const ensureSyncedSharedLabelsColors =
(metadata: JsonObject, forceFresh = false) =>
- (dispatch: Dispatch, getState: GetState): void => {
+ (dispatch: AppDispatch, getState: GetState): void => {
const syncSharedLabelsColors = (): void => {
const {
dashboardState: { sharedLabelsColorsMustSync },
@@ -1424,7 +1409,7 @@ export const ensureSyncedSharedLabelsColors =
dispatch(
setDashboardMetadata({
shared_label_colors: freshLabelsColors,
- }) as unknown as AnyAction,
+ }),
);
}
@@ -1445,7 +1430,7 @@ export const ensureSyncedSharedLabelsColors =
*/
export const updateDashboardLabelsColor =
(renderedChartIds: number[]) =>
- (_: Dispatch, getState: GetState): void => {
+ (_: AppDispatch, getState: GetState): void => {
try {
const {
dashboardInfo: { metadata },
diff --git a/superset-frontend/src/dashboard/actions/hydrate.ts b/superset-frontend/src/dashboard/actions/hydrate.ts
index 0ff43faa093..494b3758c2e 100644
--- a/superset-frontend/src/dashboard/actions/hydrate.ts
+++ b/superset-frontend/src/dashboard/actions/hydrate.ts
@@ -18,7 +18,8 @@
*/
/* eslint-disable camelcase */
import { DataMaskStateWithId, JsonObject } from '@superset-ui/core';
-import { AnyAction, Dispatch } from 'redux';
+import type { AnyAction } from 'redux';
+import type { ThunkDispatch } from 'redux-thunk';
// eslint-disable-next-line import/no-extraneous-dependencies
import type { History } from 'history';
import { chart } from 'src/components/Chart/chartReducer';
@@ -69,6 +70,7 @@ import {
export const HYDRATE_DASHBOARD = 'HYDRATE_DASHBOARD';
type GetState = () => RootState;
+type AppDispatch = ThunkDispatch<RootState, undefined, AnyAction>;
interface HydrateChartData {
slice_id: number;
@@ -82,13 +84,9 @@ interface HydrateChartData {
changed_on: string;
}
-interface HydrateDashboardData {
+interface HydrateDashboardData extends Dashboard {
metadata: JsonObject;
position_data: Record<string, LayoutItem> | null;
- dashboard_title: string;
- published: boolean;
- css: string | null;
- changed_on: string;
[key: string]: unknown;
}
@@ -110,7 +108,7 @@ export const hydrateDashboard =
activeTabs,
chartStates,
}: HydrateDashboardParams) =>
- (dispatch: Dispatch, getState: GetState): AnyAction => {
+ (dispatch: AppDispatch, getState: GetState): AnyAction => {
const { user, common, dashboardState } = getState();
const { metadata, position_data: positionData } = dashboard;
const regularUrlParams = extractUrlParams('regular');
@@ -123,13 +121,13 @@ export const hydrateDashboard =
});
// new dash: position_json could be {} or null
- const layout: Record<string, LayoutItem | DashboardEntity> =
+ // getEmptyLayout() includes a version string entry plus BasicLayoutItem entries
+ // which lack the `meta` field; layout is mutated below to add full LayoutItem entries
+ const layout = (
positionData && Object.keys(positionData).length > 0
? positionData
- : (getEmptyLayout() as unknown as Record<
- string,
- LayoutItem | DashboardEntity
- >);
+ : getEmptyLayout()
+ ) as Record<string, LayoutItem | DashboardEntity>;
// create a lookup to sync layout names with slice names
const chartIdToLayoutId: Record<number, string> = {};
@@ -143,9 +141,7 @@ export const hydrateDashboard =
});
// find root level chart container node for newly-added slices
- const parentId = findFirstParentContainerId(
- layout as unknown as DashboardLayout,
- );
+ const parentId = findFirstParentContainerId(layout as DashboardLayout);
const parent = layout[parentId];
let newSlicesContainer: DashboardEntity | undefined;
let newSlicesContainerWidth = 0;
@@ -219,9 +215,7 @@ export const hydrateDashboard =
layout[chartHolder.id] = chartHolder;
newSlicesContainer!.children.push(chartHolder.id);
- const holderChartId = (
- chartHolder.meta as unknown as LayoutItem['meta']
- ).chartId;
+ const holderChartId = chartHolder.meta.chartId;
if (holderChartId !== undefined) {
chartIdToLayoutId[holderChartId] = chartHolder.id;
}
@@ -245,7 +239,7 @@ export const hydrateDashboard =
) {
updateComponentParentsList({
currentComponent: layout[DASHBOARD_ROOT_ID] as LayoutItem,
- layout: layout as unknown as Record<string, LayoutItem>,
+ layout: layout as Record<string, LayoutItem>,
});
}
@@ -253,7 +247,7 @@ export const hydrateDashboard =
dashboardFilters: dashboardFilters as Parameters<
typeof buildActiveFilters
>[0]['dashboardFilters'],
- components: layout as unknown as Record<string, LayoutItem>,
+ components: layout as Record<string, LayoutItem>,
});
// store the header as a layout component so we can undo/redo changes
@@ -320,10 +314,7 @@ export const hydrateDashboard =
metadata.global_chart_configuration = globalChartConfiguration;
const { roles } = user;
- const canEdit = canUserEditDashboard(
- dashboard as unknown as Dashboard,
- user,
- );
+ const canEdit = canUserEditDashboard(dashboard, user);
const crossFiltersEnabled = isCrossFiltersEnabled(
metadata.cross_filters_enabled as boolean | undefined,
);
@@ -339,10 +330,7 @@ export const hydrateDashboard =
metadata,
userId: user.userId ? String(user.userId) : null, // legacy, please use state.user instead
dash_edit_perm: canEdit,
- dash_save_perm: canUserSaveAsDashboard(
- dashboard as unknown as Dashboard,
- user,
- ),
+ dash_save_perm: canUserSaveAsDashboard(dashboard, user),
dash_share_perm: findPermission(
'can_share_dashboard',
'Superset',
diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
index c45563616a4..e9a04342264 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
@@ -533,7 +533,6 @@ const DashboardBuilder = () => {
]}
editMode={editMode}
>
- {/* @ts-ignore */}
<DashboardComponent
id={topLevelTabs?.id}
parentId={DASHBOARD_ROOT_ID}
@@ -628,7 +627,6 @@ const DashboardBuilder = () => {
ref={headerRef}
filterBarWidth={headerFilterBarWidth}
>
- {/* @ts-ignore */}
<Droppable
data-test="top-level-tabs"
className={cx(!topLevelTabs && editMode && 'empty-droptarget')}
diff --git a/superset-frontend/src/dashboard/components/SliceAdder.tsx b/superset-frontend/src/dashboard/components/SliceAdder.tsx
index a79a300c645..afe5d2056fb 100644
--- a/superset-frontend/src/dashboard/components/SliceAdder.tsx
+++ b/superset-frontend/src/dashboard/components/SliceAdder.tsx
@@ -20,7 +20,7 @@
import { Component } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import { FixedSizeList as List } from 'react-window';
-// @ts-ignore
+// @ts-expect-error
import { createFilter } from 'react-search-input';
import { t } from '@apache-superset/core';
import { styled, css } from '@apache-superset/core/ui';
diff --git a/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx b/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
index b7bc53eb5a1..e09498d2289 100644
--- a/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
@@ -207,37 +207,21 @@ test('Should render', () => {
test('Should render - default props', () => {
const props = createProps();
- // @ts-ignore
delete props.forceRefresh;
- // @ts-ignore
delete props.updateSliceName;
- // @ts-ignore
delete props.toggleExpandSlice;
- // @ts-ignore
delete props.logExploreChart;
- // @ts-ignore
delete props.exportCSV;
- // @ts-ignore
delete props.innerRef;
- // @ts-ignore
delete props.editMode;
- // @ts-ignore
delete props.annotationQuery;
- // @ts-ignore
delete props.annotationError;
- // @ts-ignore
delete props.cachedDttm;
- // @ts-ignore
delete props.updatedDttm;
- // @ts-ignore
delete props.isCached;
- // @ts-ignore
delete props.isExpanded;
- // @ts-ignore
delete props.sliceName;
- // @ts-ignore
delete props.supersetCanExplore;
- // @ts-ignore
delete props.supersetCanCSV;
render(<SliceHeader {...props} />, {
@@ -251,37 +235,21 @@ test('Should render - default props', () => {
test('Should render default props and "call" actions', () => {
const props = createProps();
- // @ts-ignore
delete props.forceRefresh;
- // @ts-ignore
delete props.updateSliceName;
- // @ts-ignore
delete props.toggleExpandSlice;
- // @ts-ignore
delete props.logExploreChart;
- // @ts-ignore
delete props.exportCSV;
- // @ts-ignore
delete props.innerRef;
- // @ts-ignore
delete props.editMode;
- // @ts-ignore
delete props.annotationQuery;
- // @ts-ignore
delete props.annotationError;
- // @ts-ignore
delete props.cachedDttm;
- // @ts-ignore
delete props.updatedDttm;
- // @ts-ignore
delete props.isCached;
- // @ts-ignore
delete props.isExpanded;
- // @ts-ignore
delete props.sliceName;
- // @ts-ignore
delete props.supersetCanExplore;
- // @ts-ignore
delete props.supersetCanCSV;
render(<SliceHeader {...props} />, {
diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx
index 2cfb971c871..b80d59f3f58 100644
--- a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx
@@ -144,23 +144,18 @@ test('Should render', () => {
test('Should render default props', () => {
const props = createProps();
- // @ts-ignore
+ // @ts-expect-error - testing with missing required props
delete props.forceRefresh;
- // @ts-ignore
delete props.toggleExpandSlice;
- // @ts-ignore
- delete props.exploreChart;
- // @ts-ignore
+ delete props.logExploreChart;
delete props.exportCSV;
- // @ts-ignore
delete props.exportXLSX;
- // @ts-ignore
+ // @ts-expect-error - testing with missing required props
delete props.cachedDttm;
- // @ts-ignore
+ // @ts-expect-error - testing with missing required props
delete props.updatedDttm;
- // @ts-ignore
+ // @ts-expect-error - testing with missing required props
delete props.isCached;
- // @ts-ignore
delete props.isExpanded;
renderWrapper(props);
diff --git a/superset-frontend/src/dashboard/components/gridComponents/DynamicComponent/DynamicComponent.tsx b/superset-frontend/src/dashboard/components/gridComponents/DynamicComponent/DynamicComponent.tsx
index f990d16b1b7..c2233dfda79 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/DynamicComponent/DynamicComponent.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/DynamicComponent/DynamicComponent.tsx
@@ -111,9 +111,7 @@ const DynamicComponent: FC<DynamicComponentProps> = ({
return (
<Draggable
- // @ts-ignore
component={component}
- // @ts-ignore
parentComponent={parentComponent}
orientation={parentComponent.type === ROW_TYPE ? 'column' : 'row'}
index={index}
diff --git a/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx b/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx
index 2a6905b5e30..3e137d2c874 100644
--- a/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx
+++ b/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx
@@ -50,7 +50,7 @@ const { location } = window;
const postDashboardPermalinkMockUrl = `http://localhost/api/v1/dashboard/${DASHBOARD_ID}/permalink`;
beforeAll((): void => {
- // @ts-ignore
+ // @ts-expect-error
delete window.location;
fetchMock.post(
postDashboardPermalinkMockUrl,
@@ -67,7 +67,6 @@ beforeEach(() => {
});
afterAll((): void => {
- // @ts-ignore
window.location = location;
});
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts
index b7b378b23c0..1191edf5e69 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts
@@ -156,7 +156,7 @@ export const useInitialization = () => {
}, 1000);
}
- // @ts-ignore
+ // @ts-expect-error
if (numberOfLoadingCharts > 0 && filterTimeout !== undefined) {
clearTimeout(filterTimeout);
}
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
index 1dc55f91df8..3abcd69dd77 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
@@ -194,7 +194,6 @@ const baseFilter: Filter = {
};
jest.mock('@superset-ui/core', () => ({
- // @ts-ignore
...jest.requireActual('@superset-ui/core'),
getChartMetadataRegistry: () => ({
get: (type: string) => {
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
index 3c79efc590b..b8c3f769856 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
@@ -324,14 +324,14 @@ const FiltersConfigForm = (
const nativeFilterAndCustomizationItems = getChartMetadataRegistry().items;
const nativeFilterVizTypes = Object.entries(nativeFilterAndCustomizationItems)
- // @ts-ignore
+ // @ts-expect-error
.filter(([, { value }]) => value.behaviors?.includes(Behavior.NativeFilter))
.map(([key]) => key as keyof typeof FILTER_SUPPORTED_TYPES);
const chartCustomizationVizTypes = Object.entries(
nativeFilterAndCustomizationItems,
)
- // @ts-ignore
+ // @ts-expect-error
.filter(([, { value }]) =>
value.behaviors?.includes(Behavior.ChartCustomization),
)
@@ -366,7 +366,7 @@ const FiltersConfigForm = (
: filterToEdit?.filterType || 'filter_select');
const hasDataset =
- // @ts-ignore
+ // @ts-expect-error
!!nativeFilterAndCustomizationItems[itemTypeField]?.value?.datasourceCount;
const getDatasetId = () => {
@@ -423,7 +423,7 @@ const FiltersConfigForm = (
const nativeFilterItem =
nativeFilterAndCustomizationItems[itemTypeField] ?? {};
- // @ts-ignore
+ // @ts-expect-error
const enableNoResults = !!nativeFilterItem.value?.enableNoResults;
const hasMetrics = hasColumn && !!metrics.length;
@@ -880,7 +880,7 @@ const FiltersConfigForm = (
ariaLabel={t('Customization type')}
options={chartCustomizationVizTypes.map(pluginKey => {
const name =
- // @ts-ignore
+ // @ts-expect-error
nativeFilterAndCustomizationItems[pluginKey]?.value
?.name;
return {
@@ -918,7 +918,7 @@ const FiltersConfigForm = (
ariaLabel={t('Filter type')}
options={nativeFilterVizTypes.map(filterType => {
const name =
- // @ts-ignore
+ // @ts-expect-error
nativeFilterAndCustomizationItems[filterType]?.value
.name;
const mappedName = name
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.test.tsx
index 3dacb09286a..b4ee34097ce 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.test.tsx
@@ -119,7 +119,6 @@ function renderControlItems(
controlItemsMap: ReturnType<typeof getControlItemsMap>,
) {
return render(
- // @ts-ignore
<>
{Object.values(controlItemsMap.controlItems).map(value => value.element)}
</>,
@@ -226,7 +225,7 @@ describe('ColumnSelect filterValues behavior', () => {
...createProps(),
formFilter: { filterType: 'filterType' },
};
- // @ts-ignore: bypass incomplete formFilter type for test
+ // @ts-expect-error: bypass incomplete formFilter type for test
const element = getControlItemsMap(props).mainControlItems.groupby
.element as React.ReactElement;
render(element);
@@ -241,7 +240,7 @@ describe('ColumnSelect filterValues behavior', () => {
...createProps(),
formFilter: { filterType: 'filterType' },
};
- // @ts-ignore: bypass incomplete formFilter type for test
+ // @ts-expect-error: bypass incomplete formFilter type for test
const element = getControlItemsMap(props).mainControlItems.groupby
.element as React.ReactElement;
render(element);
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/NativeFiltersModal.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/NativeFiltersModal.test.tsx
index 2ef685b3382..9ee2a9130ab 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/NativeFiltersModal.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/NativeFiltersModal.test.tsx
@@ -34,7 +34,6 @@ Object.defineProperty(window, 'matchMedia', {
});
jest.mock('@superset-ui/core', () => ({
- // @ts-ignore
...jest.requireActual('@superset-ui/core'),
getChartMetadataRegistry: () => ({
items: {
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/utils.ts b/superset-frontend/src/dashboard/components/nativeFilters/utils.ts
index e41a5da4466..de988be8e5a 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/utils.ts
+++ b/superset-frontend/src/dashboard/components/nativeFilters/utils.ts
@@ -136,7 +136,7 @@ export function mergeExtraFormData(
}
export function isCrossFilter(vizType: string) {
- // @ts-ignore need export from superset-ui `ItemWithValue`
+ // @ts-expect-error need export from superset-ui `ItemWithValue`
return getChartMetadataRegistry().items[vizType]?.value.behaviors?.includes(
Behavior.InteractiveChart,
);
diff --git a/superset-frontend/src/dashboard/components/resizable/ResizableContainer.tsx b/superset-frontend/src/dashboard/components/resizable/ResizableContainer.tsx
index 43f83690288..d9d6ea8d501 100644
--- a/superset-frontend/src/dashboard/components/resizable/ResizableContainer.tsx
+++ b/superset-frontend/src/dashboard/components/resizable/ResizableContainer.tsx
@@ -62,7 +62,7 @@ const HANDLE_CLASSES = {
right: 'resizable-container-handle--right',
bottom: 'resizable-container-handle--bottom',
};
-// @ts-ignore
+// @ts-expect-error
const StyledResizable = styled(Resizable)`
${({ theme }) => css`
&.resizable-container {
@@ -205,7 +205,7 @@ export default function ResizableContainer({
width: adjustableWidth ? nextWidthMultiple : 0,
height: adjustableHeight ? nextHeightMultiple : 0,
},
- // @ts-ignore
+ // @ts-expect-error
id,
);
}
diff --git a/superset-frontend/src/dashboard/util/crossFilters.test.ts b/superset-frontend/src/dashboard/util/crossFilters.test.ts
index 8523719ef4e..d6519dcec64 100644
--- a/superset-frontend/src/dashboard/util/crossFilters.test.ts
+++ b/superset-frontend/src/dashboard/util/crossFilters.test.ts
@@ -135,7 +135,6 @@ const mockedGetChartMetadataRegistry = getChartMetadataRegistry as jest.Mock;
beforeEach(() => {
mockedGetChartMetadataRegistry.mockImplementation(() => ({
- // @ts-ignore
get: () => ({
behaviors: [Behavior.InteractiveChart],
}),
@@ -147,7 +146,7 @@ afterEach(() => {
});
test('Generate correct cross filters configuration without initial configuration', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(getCrossFiltersConfiguration(DASHBOARD_LAYOUT, {}, CHARTS)).toEqual({
chartConfiguration: {
'1': {
diff --git a/superset-frontend/src/dashboard/util/extractUrlParams.test.ts b/superset-frontend/src/dashboard/util/extractUrlParams.test.ts
index c2eea4512a4..98f79dd214a 100644
--- a/superset-frontend/src/dashboard/util/extractUrlParams.test.ts
+++ b/superset-frontend/src/dashboard/util/extractUrlParams.test.ts
@@ -23,9 +23,9 @@ const originalWindowLocation = window.location;
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
describe('extractUrlParams', () => {
beforeAll(() => {
- // @ts-ignore
+ // @ts-expect-error
delete window.location;
- // @ts-ignore
+ // @ts-expect-error
window.location = { search: '?edit=true&abc=123' };
});
diff --git a/superset-frontend/src/dashboard/util/findParentId.test.ts b/superset-frontend/src/dashboard/util/findParentId.test.ts
index 413816d749e..113518ef2a5 100644
--- a/superset-frontend/src/dashboard/util/findParentId.test.ts
+++ b/superset-frontend/src/dashboard/util/findParentId.test.ts
@@ -44,13 +44,13 @@ describe('findParentId', () => {
});
test('should not throw error and return null with bad / missing inputs', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(findParentId(null)).toBeNull();
- // @ts-ignore
+ // @ts-expect-error
expect(findParentId({ layout })).toBeNull();
- // @ts-ignore
+ // @ts-expect-error
expect(findParentId({ childId: 'a' })).toBeNull();
- // @ts-ignore
+ // @ts-expect-error
expect(findParentId({ childId: 'a', layout: null })).toBeNull();
});
});
diff --git a/superset-frontend/src/dashboard/util/propShapes.tsx b/superset-frontend/src/dashboard/util/propShapes.tsx
index 4dd8055674e..5ced7dd95c6 100644
--- a/superset-frontend/src/dashboard/util/propShapes.tsx
+++ b/superset-frontend/src/dashboard/util/propShapes.tsx
@@ -16,8 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-import PropTypes from 'prop-types';
-import componentTypes from './componentTypes';
import backgroundStyleOptions from './backgroundStyleOptions';
import headerStyleOptions from './headerStyleOptions';
import type { JsonObject } from '@superset-ui/core';
@@ -114,95 +112,3 @@ export interface FilterScopeParentNode extends FilterScopeLeafNode {
}
export type FilterScopeTreeNode = FilterScopeParentNode | FilterScopeLeafNode;
-
-// PropTypes shapes (kept for backward compatibility with components
-// that have not been migrated to TypeScript interfaces)
-
-export const componentShape = PropTypes.shape({
- id: PropTypes.string.isRequired,
- type: PropTypes.oneOf(Object.values(componentTypes)).isRequired,
- parents: PropTypes.arrayOf(PropTypes.string),
- children: PropTypes.arrayOf(PropTypes.string),
- meta: PropTypes.shape({
- // Dimensions
- width: PropTypes.number,
- height: PropTypes.number,
-
- // Header
- headerSize: PropTypes.oneOf(headerStyleOptions.map(opt => opt.value)),
-
- // Row
- background: PropTypes.oneOf(backgroundStyleOptions.map(opt => opt.value)),
-
- // Chart
- chartId: PropTypes.number,
- }),
-});
-
-export const chartPropShape = PropTypes.shape({
- id: PropTypes.number.isRequired,
- chartAlert: PropTypes.string,
- chartStatus: PropTypes.string,
- chartUpdateEndTime: PropTypes.number,
- chartUpdateStartTime: PropTypes.number,
- latestQueryFormData: PropTypes.object,
- queryController: PropTypes.shape({ abort: PropTypes.func }),
- queriesResponse: PropTypes.arrayOf(PropTypes.object),
- triggerQuery: PropTypes.bool,
- lastRendered: PropTypes.number,
-});
-
-export const slicePropShape = PropTypes.shape({
- slice_id: PropTypes.number.isRequired,
- slice_url: PropTypes.string.isRequired,
- slice_name: PropTypes.string.isRequired,
- datasource: PropTypes.string,
- datasource_name: PropTypes.string,
- datasource_link: PropTypes.string,
- changed_on: PropTypes.number.isRequired,
- modified: PropTypes.string,
- viz_type: PropTypes.string.isRequired,
- description: PropTypes.string,
- description_markeddown: PropTypes.string,
- owners: PropTypes.arrayOf(PropTypes.string),
-});
-
-export const dashboardFilterPropShape = PropTypes.shape({
- chartId: PropTypes.number.isRequired,
- componentId: PropTypes.string.isRequired,
- filterName: PropTypes.string.isRequired,
- datasourceId: PropTypes.string.isRequired,
- directPathToFilter: PropTypes.arrayOf(PropTypes.string).isRequired,
- isDateFilter: PropTypes.bool.isRequired,
- isInstantFilter: PropTypes.bool.isRequired,
- columns: PropTypes.object,
- labels: PropTypes.object,
- scopes: PropTypes.object,
-});
-
-export const dashboardStatePropShape = PropTypes.shape({
- sliceIds: PropTypes.arrayOf(PropTypes.number),
- expandedSlices: PropTypes.object,
- editMode: PropTypes.bool,
- isPublished: PropTypes.bool,
- colorNamespace: PropTypes.string,
- colorScheme: PropTypes.string,
- updatedColorScheme: PropTypes.bool,
- hasUnsavedChanges: PropTypes.bool,
-});
-
-export const dashboardInfoPropShape = PropTypes.shape({
- id: PropTypes.number,
- metadata: PropTypes.object,
- slug: PropTypes.string,
- dash_edit_perm: PropTypes.bool,
- dash_save_perm: PropTypes.bool,
- common: PropTypes.object,
- userId: PropTypes.string,
-});
-
-export const filterScopeSelectorTreeNodePropShape = PropTypes.shape({
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
- label: PropTypes.string.isRequired,
- children: PropTypes.arrayOf(PropTypes.object),
-});
diff --git a/superset-frontend/src/embedded/EmbeddedContextProviders.tsx b/superset-frontend/src/embedded/EmbeddedContextProviders.tsx
index c7b2b48ae8e..ccb8f562c6d 100644
--- a/superset-frontend/src/embedded/EmbeddedContextProviders.tsx
+++ b/superset-frontend/src/embedded/EmbeddedContextProviders.tsx
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Route } from 'react-router-dom';
import { getExtensionsRegistry } from '@superset-ui/core';
import { Provider as ReduxProvider } from 'react-redux';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { DynamicPluginProvider } from 'src/components';
@@ -68,10 +68,7 @@ export const EmbeddedContextProviders: React.FC = ({ children }) => {
<DndProvider backend={HTML5Backend}>
<EmbeddedUiConfigProvider>
<DynamicPluginProvider>
- <QueryParamProvider
- ReactRouterRoute={Route}
- stringifyOptions={{ encode: false }}
- >
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
{RootContextProviderExtension ? (
<RootContextProviderExtension>
{children}
diff --git a/superset-frontend/src/explore/actions/datasourcesActions.test.ts b/superset-frontend/src/explore/actions/datasourcesActions.test.ts
index c3e0893c9d8..4f2c29322a6 100644
--- a/superset-frontend/src/explore/actions/datasourcesActions.test.ts
+++ b/superset-frontend/src/explore/actions/datasourcesActions.test.ts
@@ -95,7 +95,7 @@ test('change datasource action', () => {
},
}));
// ignore getState type check - we dont need explore.datasource field for this test
- // @ts-ignore
+ // @ts-expect-error
changeDatasource(NEW_DATASOURCE)(dispatch, getState);
expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenNthCalledWith(1, setDatasource(NEW_DATASOURCE));
diff --git a/superset-frontend/src/explore/actions/hydrateExplore.test.ts b/superset-frontend/src/explore/actions/hydrateExplore.test.ts
index 6fe24882bc5..31afeb01c9d 100644
--- a/superset-frontend/src/explore/actions/hydrateExplore.test.ts
+++ b/superset-frontend/src/explore/actions/hydrateExplore.test.ts
@@ -31,7 +31,7 @@ test('creates hydrate action from initial data', () => {
explore: {},
}));
// ignore type check - we dont need exact explore state for this test
- // @ts-ignore
+ // @ts-expect-error
hydrateExplore(exploreInitialData)(dispatch, getState);
expect(dispatch).toHaveBeenCalledWith(
expect.objectContaining({
@@ -104,7 +104,7 @@ test('creates hydrate action with existing state', () => {
explore: { controlsTransferred: ['all_columns'] },
}));
// ignore type check - we dont need exact explore state for this test
- // @ts-ignore
+ // @ts-expect-error
hydrateExplore(exploreInitialData)(dispatch, getState);
expect(dispatch).toHaveBeenCalledWith(
expect.objectContaining({
@@ -181,7 +181,7 @@ test('uses configured default time range if not set', () => {
},
explore: {},
}));
- // @ts-ignore
+ // @ts-expect-error
hydrateExplore({ form_data: {}, slice: {}, dataset: {} })(dispatch, getState);
expect(dispatch).toHaveBeenCalledWith(
expect.objectContaining({
@@ -199,7 +199,7 @@ test('uses configured default time range if not set', () => {
slice: {},
dataset: {},
};
- // @ts-ignore
+ // @ts-expect-error
hydrateExplore(withTimeRangeSet)(dispatch, getState);
expect(dispatch).toHaveBeenCalledWith(
expect.objectContaining({
@@ -239,10 +239,10 @@ test('extracts currency formats from metrics in dataset', () => {
],
};
- // @ts-ignore
+ // @ts-expect-error
hydrateExplore({ ...exploreInitialData, dataset: datasetWithMetrics })(
dispatch,
- // @ts-ignore
+ // @ts-expect-error
getState,
);
diff --git a/superset-frontend/src/explore/components/DataTableControl/CopyToClipboardButton.test.tsx b/superset-frontend/src/explore/components/DataTableControl/CopyToClipboardButton.test.tsx
index 9daa3db175f..dafe14902e3 100644
--- a/superset-frontend/src/explore/components/DataTableControl/CopyToClipboardButton.test.tsx
+++ b/superset-frontend/src/explore/components/DataTableControl/CopyToClipboardButton.test.tsx
@@ -36,7 +36,7 @@ test('Should copy to clipboard', async () => {
document.execCommand = callback;
const originalClipboard = { ...global.navigator.clipboard };
- // @ts-ignore
+ // @ts-expect-error
global.navigator.clipboard = { write: callback, writeText: callback };
render(<CopyToClipboardButton data={[{ copy: 'data', data: 'copy' }]} />, {
@@ -51,6 +51,6 @@ test('Should copy to clipboard', async () => {
});
jest.resetAllMocks();
- // @ts-ignore
+ // @ts-expect-error
global.navigator.clipboard = originalClipboard;
});
diff --git a/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx b/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx
index 1d5fc7a63ff..90d3747d6fe 100644
--- a/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx
+++ b/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx
@@ -185,7 +185,7 @@ describe('DataTablesPane', () => {
});
test('Displaying the data pane is under featureflag', () => {
- // @ts-ignore
+ // @ts-expect-error
global.featureFlags = {
[FeatureFlag.DatapanelClosedByDefault]: true,
};
diff --git a/superset-frontend/src/explore/components/DatasourcePanel/index.tsx b/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
index f1c20cc684c..1278a2282f1 100644
--- a/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
+++ b/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
@@ -326,7 +326,7 @@ export default function DataSourcePanel({
formData={formData}
/>
)}
- {/* @ts-ignore */}
+ {/* @ts-expect-error */}
<Control {...datasourceControl} name="datasource" actions={actions} />
{datasource.id != null && mainBody}
</DatasourceContainer>
diff --git a/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx b/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
index 11dd1ca686a..f9f7672aa48 100644
--- a/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import React, { Component } from 'react';
-import PropTypes from 'prop-types';
import { IconTooltip, List } from '@superset-ui/core/components';
import { nanoid } from 'nanoid';
import { t } from '@apache-superset/core';
@@ -58,21 +57,6 @@ interface CollectionControlProps {
theme: SupersetTheme;
}
-const propTypes = {
- name: PropTypes.string.isRequired,
- label: PropTypes.string,
- description: PropTypes.string,
- placeholder: PropTypes.string,
- addTooltip: PropTypes.string,
- itemGenerator: PropTypes.func,
- keyAccessor: PropTypes.func,
- onChange: PropTypes.func,
- value: PropTypes.oneOfType([PropTypes.array]),
- isFloat: PropTypes.bool,
- isInt: PropTypes.bool,
- controlName: PropTypes.string.isRequired,
-};
-
const defaultProps: Partial<CollectionControlProps> = {
label: null,
description: null,
@@ -95,8 +79,6 @@ const SortableDragger = SortableHandle(() => (
));
class CollectionControl extends Component<CollectionControlProps> {
- static propTypes = propTypes;
-
static defaultProps = defaultProps;
constructor(props: CollectionControlProps) {
diff --git a/superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx b/superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx
index f6a150cf011..cd35882d5ed 100644
--- a/superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx
+++ b/superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx
@@ -114,7 +114,7 @@ export function ControlFormItem({
hovered={hovered}
/>
)}
- {/* @ts-ignore */}
+ {/* @ts-expect-error - dynamic Control component has varying prop types */}
<Control {...props} value={value} onChange={handleChange} />
</>
)}
diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx b/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
index 5f982bb8d1f..3557355c7cd 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
@@ -41,7 +41,6 @@ beforeEach(() => {
});
afterEach(() => {
- // @ts-ignore
window.location = originalLocation;
fetchMock.clearHistory().removeRoutes();
jest.clearAllMocks(); // Clears mock history but keeps spy in place
@@ -524,9 +523,9 @@ test('should show missing params state', () => {
});
test('should show missing dataset state', () => {
- // @ts-ignore
+ // @ts-expect-error - overriding window.location for test
delete window.location;
- // @ts-ignore
+ // @ts-expect-error - overriding window.location for test
window.location = { search: '?slice_id=152' };
const props = createProps({ datasource: fallbackExploreInitialData.dataset });
render(<DatasourceControl {...props} />, { useRedux: true, useRouter: true });
@@ -539,9 +538,9 @@ test('should show missing dataset state', () => {
});
test('should show forbidden dataset state', () => {
- // @ts-ignore
+ // @ts-expect-error - overriding window.location for test
delete window.location;
- // @ts-ignore
+ // @ts-expect-error - overriding window.location for test
window.location = { search: '?slice_id=152' };
const error = {
error_type: 'TABLE_SECURITY_ACCESS_ERROR',
diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx b/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx
index e698b036e87..968c00d20a4 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl/index.tsx
@@ -19,7 +19,6 @@
*/
import React, { PureComponent } from 'react';
-import PropTypes from 'prop-types';
import { DatasourceType, SupersetClient, Datasource } from '@superset-ui/core';
import { t } from '@apache-superset/core';
import {
@@ -119,25 +118,6 @@ interface DatasourceControlState {
showDatasource?: boolean;
}
-const propTypes = {
- actions: PropTypes.object.isRequired,
- onChange: PropTypes.func,
- value: PropTypes.string,
- datasource: PropTypes.object.isRequired,
- form_data: PropTypes.object.isRequired,
- isEditable: PropTypes.bool,
- onDatasourceSave: PropTypes.func,
- user: PropTypes.object.isRequired,
- // ControlHeader-related props
- hovered: PropTypes.bool,
- type: PropTypes.string,
- label: PropTypes.string,
- default: PropTypes.any,
- description: PropTypes.string,
- validationErrors: PropTypes.array,
- name: PropTypes.string,
-};
-
const defaultProps = {
onChange: () => {},
onDatasourceSave: null,
@@ -258,8 +238,6 @@ class DatasourceControl extends PureComponent<
DatasourceControlProps,
DatasourceControlState
> {
- static propTypes = propTypes;
-
static defaultProps = defaultProps;
constructor(props: DatasourceControlProps) {
diff --git a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
index 5eade7c64e0..0b71b855317 100644
--- a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
+++ b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
@@ -351,7 +351,7 @@ const ColumnSelectPopover = ({
tab => {
getCurrentTab(tab);
setSelectedTab(tab);
- // @ts-ignore
+ // @ts-expect-error - AceEditor ref type doesn't expose editor.focus()
sqlEditorRef.current?.editor.focus();
},
[getCurrentTab],
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 2f7b34fc30a..1de2aee0a88 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.tsx
@@ -17,15 +17,12 @@
* under the License.
*/
import { Component, ReactNode } from 'react';
-import PropTypes from 'prop-types';
import { SupersetClient, ensureIsArray } from '@superset-ui/core';
import { logging } from '@apache-superset/core';
import { t } from '@apache-superset/core';
import { withTheme, type SupersetTheme } from '@apache-superset/core/ui';
import ControlHeader from 'src/explore/components/ControlHeader';
-import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
-import savedMetricType from 'src/explore/components/controls/MetricControl/savedMetricType';
import AdhocMetric, {
isDictionaryForAdhocMetric,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';
@@ -46,8 +43,6 @@ import AdhocFilterOption from 'src/explore/components/controls/FilterControl/Adh
import AdhocFilter, {
isDictionaryForAdhocFilter,
} from 'src/explore/components/controls/FilterControl/AdhocFilter';
-import adhocFilterType from 'src/explore/components/controls/FilterControl/adhocFilterType';
-import columnType from 'src/explore/components/controls/FilterControl/columnType';
import { toQueryString } from 'src/utils/urlUtils';
import { Clauses, ExpressionTypes } from '../types';
@@ -109,29 +104,6 @@ interface AdhocFilterControlState {
const { warning } = Modal;
-const selectedMetricType = PropTypes.oneOfType([
- PropTypes.string,
- adhocMetricType,
-]);
-
-const propTypes = {
- label: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
- name: PropTypes.string,
- sections: PropTypes.arrayOf(PropTypes.string),
- operators: PropTypes.arrayOf(PropTypes.string),
- onChange: PropTypes.func,
- value: PropTypes.arrayOf(adhocFilterType),
- datasource: PropTypes.object,
- columns: PropTypes.arrayOf(columnType),
- savedMetrics: PropTypes.arrayOf(savedMetricType),
- selectedMetrics: PropTypes.oneOfType([
- selectedMetricType,
- PropTypes.arrayOf(selectedMetricType),
- ]),
- isLoading: PropTypes.bool,
- canDelete: PropTypes.func,
-};
-
const defaultProps = {
name: '',
onChange: () => {},
@@ -440,10 +412,7 @@ class AdhocFilterControl extends Component<
}
}
-// Static properties are defined in the class using static keyword
-// @ts-expect-error - propTypes are defined for runtime validation but TypeScript handles type checking
-AdhocFilterControl.propTypes = propTypes;
-// @ts-expect-error - defaultProps for backward compatibility with PropTypes
+// @ts-expect-error - defaultProps for backward compatibility
AdhocFilterControl.defaultProps = defaultProps;
export default withTheme(AdhocFilterControl);
diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.tsx
index 911d2a16b32..1456543505e 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.tsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.tsx
@@ -18,7 +18,6 @@
*/
import type React from 'react';
import { createRef, Component, type RefObject } from 'react';
-import PropTypes from 'prop-types';
import type { SupersetTheme } from '@apache-superset/core/ui';
import { Button, Icons, Select } from '@superset-ui/core/components';
import { ErrorBoundary } from 'src/components';
@@ -27,11 +26,9 @@ import { t } from '@apache-superset/core';
import { styled } from '@apache-superset/core/ui';
import Tabs from '@superset-ui/core/components/Tabs';
-import adhocMetricType from 'src/explore/components/controls/MetricControl/adhocMetricType';
import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilter';
import AdhocFilterEditPopoverSimpleTabContent from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent';
import AdhocFilterEditPopoverSqlTabContent from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent';
-import columnType from 'src/explore/components/controls/FilterControl/columnType';
import type { Dataset } from '@superset-ui/chart-controls';
import type { ColumnType } from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent';
import {
@@ -80,26 +77,6 @@ interface AdhocFilterEditPopoverState {
hasLayerFilterScopeChanged: boolean;
}
-const propTypes = {
- adhocFilter: PropTypes.instanceOf(AdhocFilter).isRequired,
- onChange: PropTypes.func.isRequired,
- onClose: PropTypes.func.isRequired,
- onResize: PropTypes.func.isRequired,
- options: PropTypes.arrayOf(
- PropTypes.oneOfType([
- columnType,
- PropTypes.shape({ saved_metric_name: PropTypes.string.isRequired }),
- adhocMetricType,
- ]),
- ).isRequired,
- datasource: PropTypes.object,
- partitionColumn: PropTypes.string,
- theme: PropTypes.object,
- sections: PropTypes.arrayOf(PropTypes.string),
- operators: PropTypes.arrayOf(PropTypes.string),
- requireSave: PropTypes.bool,
-};
-
const FilterPopoverContentContainer = styled.div`
.adhoc-filter-edit-tabs > .nav-tabs {
margin-bottom: ${({ theme }) => theme.sizeUnit * 2}px;
@@ -503,6 +480,3 @@ export default class AdhocFilterEditPopover extends Component<
);
}
}
-
-// @ts-expect-error - propTypes are defined for runtime validation but TypeScript handles type checking
-AdhocFilterEditPopover.propTypes = propTypes;
diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent/index.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent/index.tsx
index 37d8fbfa270..8432181ce9d 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent/index.tsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent/index.tsx
@@ -53,7 +53,7 @@ export default function AdhocFilterEditPopoverSqlTabContent({
const theme = useTheme();
useEffect(() => {
- // @ts-ignore
+ // @ts-expect-error - AceEditor ref type doesn't expose editor.resize()
aceEditorRef?.current?.editor.resize();
}, [adhocFilter]);
diff --git a/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts b/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts
index df2e663f7a8..0d32c7d7f0d 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts
+++ b/superset-frontend/src/explore/components/controls/FilterControl/adhocFilterType.ts
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { InferProps } from 'prop-types';
import { Clauses, ExpressionTypes } from './types';
export interface AdhocFilterSimple {
@@ -51,14 +50,3 @@ export interface AdhocFilterSql {
}
export type AdhocFilterType = AdhocFilterSimple | AdhocFilterSql;
-
-// PropTypes validation function - babel-plugin-typescript-to-proptypes automatically
-// generates PropTypes from the TypeScript interface above
-export default function AdhocFilterValidator(props: {
- filter: AdhocFilterType;
-}) {
- return null; // PropTypes auto-generated by babel plugin
-}
-
-// For consumers needing PropTypes type inference
-export type AdhocFilterProps = InferProps<typeof AdhocFilterValidator>;
diff --git a/superset-frontend/src/explore/components/controls/FilterControl/utils/translateToSQL.ts b/superset-frontend/src/explore/components/controls/FilterControl/utils/translateToSQL.ts
index 98d0481ceac..171ddbc6f52 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/utils/translateToSQL.ts
+++ b/superset-frontend/src/explore/components/controls/FilterControl/utils/translateToSQL.ts
@@ -65,11 +65,10 @@ export const translateToSql = (
// 'LATEST PARTITION' supported callback only
operator ===
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.LatestPartition].operation
- ? // @ts-ignore TODO: fix missing operator type `NOT LIKE` and `TEMPORAL RANGE`
- // Also to fix type incompability between AdhocFilter and Latest Partition callback args.
+ ? // @ts-expect-error TODO: fix missing operator type `NOT LIKE` and `TEMPORAL RANGE`
+ // Also to fix type incompatibility between AdhocFilter and Latest Partition callback args.
OPERATORS_TO_SQL[operator](adhocFilter)
- : // @ts-ignore
- // @ts-ignore TODO: fix missing operator type `NOT LIKE` and `TEMPORAL RANGE`.
+ : // @ts-expect-error TODO: fix missing operator type `NOT LIKE` and `TEMPORAL RANGE`.
OPERATORS_TO_SQL[operator];
return getSimpleSQLExpression(subject, op, comparator);
}
diff --git a/superset-frontend/src/explore/components/controls/FixedOrMetricControl/index.tsx b/superset-frontend/src/explore/components/controls/FixedOrMetricControl/index.tsx
index 4a2d59f8703..74189cf91d9 100644
--- a/superset-frontend/src/explore/components/controls/FixedOrMetricControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/FixedOrMetricControl/index.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import { Component } from 'react';
-import PropTypes from 'prop-types';
import { t } from '@apache-superset/core';
import { Collapse, Label } from '@superset-ui/core/components';
import TextControl from 'src/explore/components/controls/TextControl';
@@ -65,17 +64,6 @@ interface FixedOrMetricControlState {
metricValue: MetricValue | null;
}
-const propTypes = {
- onChange: PropTypes.func,
- value: PropTypes.object,
- isFloat: PropTypes.bool,
- datasource: PropTypes.object.isRequired,
- default: PropTypes.shape({
- type: PropTypes.oneOf(['fix', 'metric']),
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- }),
-};
-
const defaultProps = {
onChange: () => {},
default: { type: controlTypes.fixed, value: 5 },
@@ -216,7 +204,5 @@ export default class FixedOrMetricControl extends Component<
}
}
-// @ts-expect-error - propTypes are defined for runtime validation but TypeScript handles type checking
-FixedOrMetricControl.propTypes = propTypes;
-// @ts-expect-error - defaultProps for backward compatibility with PropTypes
+// @ts-expect-error - defaultProps for backward compatibility
FixedOrMetricControl.defaultProps = defaultProps;
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/index.tsx b/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/index.tsx
index a43a623c5ed..fc90dbf4eb0 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/index.tsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/index.tsx
@@ -18,7 +18,6 @@
*/
/* eslint-disable camelcase */
import { PureComponent, createRef } from 'react';
-import PropTypes from 'prop-types';
import { isDefined, ensureIsArray, DatasourceType } from '@superset-ui/core';
import { t } from '@apache-superset/core';
import type { editors } from '@apache-superset/core';
@@ -40,8 +39,6 @@ import {
POPOVER_INITIAL_HEIGHT,
POPOVER_INITIAL_WIDTH,
} from 'src/explore/constants';
-import columnType from 'src/explore/components/controls/MetricControl/columnType';
-import savedMetricType from 'src/explore/components/controls/MetricControl/savedMetricType';
import AdhocMetric, {
EXPRESSION_TYPES,
} from 'src/explore/components/controls/MetricControl/AdhocMetric';
@@ -106,21 +103,6 @@ interface AdhocMetricEditPopoverState {
height: number;
}
-const propTypes = {
- onChange: PropTypes.func.isRequired,
- onClose: PropTypes.func.isRequired,
- onResize: PropTypes.func.isRequired,
- getCurrentTab: PropTypes.func,
- getCurrentLabel: PropTypes.func,
- adhocMetric: PropTypes.instanceOf(AdhocMetric).isRequired,
- columns: PropTypes.arrayOf(columnType),
- savedMetricsOptions: PropTypes.arrayOf(savedMetricType),
- savedMetric: savedMetricType,
- datasource: PropTypes.object,
- isNewMetric: PropTypes.bool,
- isLabelModified: PropTypes.bool,
-};
-
const defaultProps = {
columns: [],
getCurrentTab: noOp,
@@ -613,7 +595,5 @@ export default class AdhocMetricEditPopover extends PureComponent<
);
}
}
-// @ts-expect-error - propTypes are defined for runtime validation but TypeScript handles type checking
-AdhocMetricEditPopover.propTypes = propTypes;
-// @ts-expect-error - defaultProps for backward compatibility with PropTypes
+// @ts-expect-error - defaultProps for backward compatibility
AdhocMetricEditPopover.defaultProps = defaultProps;
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.tsx b/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.tsx
index 34a016e9864..c562dc2556c 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.tsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.tsx
@@ -17,15 +17,12 @@
* under the License.
*/
import { PureComponent } from 'react';
-import PropTypes from 'prop-types';
import { Metric } from '@superset-ui/core';
import { OptionControlLabel } from 'src/explore/components/controls/OptionControls';
import { DndItemType } from 'src/explore/components/DndItemType';
import { Datasource } from 'src/explore/types';
import { ISaveableDatasource } from 'src/SqlLab/components/SaveDatasetModal';
-import columnType from './columnType';
import AdhocMetric from './AdhocMetric';
-import savedMetricType from './savedMetricType';
import AdhocMetricPopoverTrigger from './AdhocMetricPopoverTrigger';
import { savedMetricType as SavedMetricTypeDef } from './types';
@@ -45,22 +42,6 @@ interface AdhocMetricOptionProps {
datasourceWarningMessage?: string;
}
-const propTypes = {
- adhocMetric: PropTypes.instanceOf(AdhocMetric),
- onMetricEdit: PropTypes.func.isRequired,
- onRemoveMetric: PropTypes.func,
- columns: PropTypes.arrayOf(columnType),
- savedMetricsOptions: PropTypes.arrayOf(savedMetricType),
- savedMetric: savedMetricType,
- datasource: PropTypes.object,
- onMoveLabel: PropTypes.func,
- onDropLabel: PropTypes.func,
- index: PropTypes.number,
- type: PropTypes.string,
- multi: PropTypes.bool,
- datasourceWarningMessage: PropTypes.string,
-};
-
class AdhocMetricOption extends PureComponent<AdhocMetricOptionProps> {
constructor(props: AdhocMetricOptionProps) {
super(props);
@@ -119,6 +100,3 @@ class AdhocMetricOption extends PureComponent<AdhocMetricOptionProps> {
}
export default AdhocMetricOption;
-
-// @ts-expect-error - propTypes are defined for runtime validation but TypeScript handles type checking
-AdhocMetricOption.propTypes = propTypes;
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/FilterDefinitionOption.tsx b/superset-frontend/src/explore/components/controls/MetricControl/FilterDefinitionOption.tsx
index c8aaf488555..c59239d0270 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/FilterDefinitionOption.tsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/FilterDefinitionOption.tsx
@@ -16,10 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-import PropTypes from 'prop-types';
-
-import columnType from './columnType';
-import adhocMetricType from './adhocMetricType';
import { StyledColumnOption } from '../../optionRenderers';
interface OptionType {
@@ -30,14 +26,6 @@ interface OptionType {
[key: string]: unknown;
}
-const propTypes = {
- option: PropTypes.oneOfType([
- columnType,
- PropTypes.shape({ saved_metric_name: PropTypes.string.isRequired }),
- adhocMetricType,
- ]).isRequired,
-};
-
export default function FilterDefinitionOption({
option,
}: {
@@ -69,4 +57,3 @@ export default function FilterDefinitionOption({
}
return null;
}
-FilterDefinitionOption.propTypes = propTypes;
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx b/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx
index 4ad35b8d679..9c2399cf25c 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx
@@ -16,14 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-import PropTypes from 'prop-types';
import { Metric } from '@superset-ui/core';
import { Datasource } from 'src/explore/types';
import { ISaveableDatasource } from 'src/SqlLab/components/SaveDatasetModal';
-import columnType from './columnType';
import AdhocMetricOption from './AdhocMetricOption';
import AdhocMetric from './AdhocMetric';
-import savedMetricType from './savedMetricType';
import { savedMetricType as SavedMetricTypeDef } from './types';
interface MetricDefinitionValueProps {
@@ -42,21 +39,6 @@ interface MetricDefinitionValueProps {
type?: string;
}
-const propTypes = {
- option: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired,
- index: PropTypes.number.isRequired,
- onMetricEdit: PropTypes.func,
- onRemoveMetric: PropTypes.func,
- onMoveLabel: PropTypes.func,
- onDropLabel: PropTypes.func,
- columns: PropTypes.arrayOf(columnType),
- savedMetrics: PropTypes.arrayOf(savedMetricType),
- savedMetricsOptions: PropTypes.arrayOf(savedMetricType),
- multi: PropTypes.bool,
- datasource: PropTypes.object,
- datasourceWarningMessage: PropTypes.string,
-};
-
export default function MetricDefinitionValue({
option,
onMetricEdit,
@@ -107,4 +89,3 @@ export default function MetricDefinitionValue({
}
return null;
}
-MetricDefinitionValue.propTypes = propTypes;
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx b/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx
index c7681410650..ce47960fcc7 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/MetricsControl.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import React, { useCallback, useEffect, useMemo, useState } from 'react';
-import PropTypes from 'prop-types';
import { ensureIsArray, usePrevious } from '@superset-ui/core';
import { t } from '@apache-superset/core';
import { isEqual } from 'lodash';
@@ -29,28 +28,10 @@ import {
HeaderContainer,
LabelsContainer,
} from 'src/explore/components/controls/OptionControls';
-import columnType from './columnType';
import MetricDefinitionValue from './MetricDefinitionValue';
import AdhocMetric from './AdhocMetric';
-import savedMetricType from './savedMetricType';
-import adhocMetricType from './adhocMetricType';
import AdhocMetricPopoverTrigger from './AdhocMetricPopoverTrigger';
-const propTypes = {
- name: PropTypes.string.isRequired,
- onChange: PropTypes.func,
- value: PropTypes.oneOfType([
- PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, adhocMetricType])),
- PropTypes.oneOfType([PropTypes.string, adhocMetricType]),
- ]),
- columns: PropTypes.arrayOf(columnType),
- savedMetrics: PropTypes.arrayOf(savedMetricType),
- isLoading: PropTypes.bool,
- multi: PropTypes.bool,
- clearable: PropTypes.bool,
- datasource: PropTypes.object,
-};
-
const defaultProps = {
onChange: () => {},
clearable: true,
@@ -370,7 +351,6 @@ const MetricsControl = ({
);
};
-MetricsControl.propTypes = propTypes;
MetricsControl.defaultProps = defaultProps;
export default MetricsControl;
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts b/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts
index 466208277cf..6519f560f1a 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts
+++ b/superset-frontend/src/explore/components/controls/MetricControl/adhocMetricType.ts
@@ -16,22 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
-import PropTypes from 'prop-types';
-
import { AGGREGATES } from 'src/explore/constants';
-import columnType from './columnType';
import { EXPRESSION_TYPES } from './AdhocMetric';
-export default PropTypes.oneOfType([
- PropTypes.shape({
- expressionType: PropTypes.oneOf([EXPRESSION_TYPES.SIMPLE]).isRequired,
- column: columnType.isRequired,
- aggregate: PropTypes.oneOf(Object.keys(AGGREGATES)).isRequired,
- label: PropTypes.string.isRequired,
- }),
- PropTypes.shape({
- expressionType: PropTypes.oneOf([EXPRESSION_TYPES.SQL]).isRequired,
- sqlExpression: PropTypes.string.isRequired,
- label: PropTypes.string.isRequired,
- }),
-]);
+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.ts b/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.ts
index 1d03345e03d..2ebc81f0ab7 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.ts
+++ b/superset-frontend/src/explore/components/controls/MetricControl/savedMetricType.ts
@@ -16,16 +16,4 @@
* specific language governing permissions and limitations
* under the License.
*/
-import PropTypes from 'prop-types';
-
export type { savedMetricType } from './types';
-
-// PropTypes definition for JavaScript files
-const savedMetricTypePropTypes = PropTypes.shape({
- metric_name: PropTypes.string.isRequired,
- verbose_name: PropTypes.string,
- expression: PropTypes.string,
-});
-
-// Export as default for backward compatibility with JavaScript files
-export default savedMetricTypePropTypes;
diff --git a/superset-frontend/src/explore/components/controls/SelectControl.tsx b/superset-frontend/src/explore/components/controls/SelectControl.tsx
index 5d640fb0ee1..751546c7f5c 100644
--- a/superset-frontend/src/explore/components/controls/SelectControl.tsx
+++ b/superset-frontend/src/explore/components/controls/SelectControl.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import { PureComponent, type ReactNode } from 'react';
-import PropTypes from 'prop-types';
import { isEqualArray } from '@superset-ui/core';
import { t } from '@apache-superset/core';
import { css } from '@apache-superset/core/ui';
@@ -72,55 +71,6 @@ export interface SelectControlProps {
sortComparator?: (a: SelectOption, b: SelectOption) => number;
}
-const propTypes = {
- ariaLabel: PropTypes.string,
- autoFocus: PropTypes.bool,
- choices: PropTypes.array,
- clearable: PropTypes.bool,
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
- disabled: PropTypes.bool,
- freeForm: PropTypes.bool,
- isLoading: PropTypes.bool,
- mode: PropTypes.string,
- multi: PropTypes.bool,
- isMulti: PropTypes.bool,
- name: PropTypes.string.isRequired,
- onChange: PropTypes.func,
- onFocus: PropTypes.func,
- onSelect: PropTypes.func,
- onDeselect: PropTypes.func,
- value: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number,
- PropTypes.array,
- ]),
- default: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number,
- PropTypes.array,
- ]),
- showHeader: PropTypes.bool,
- optionRenderer: PropTypes.func,
- valueKey: PropTypes.string,
- options: PropTypes.array,
- placeholder: PropTypes.string,
- filterOption: PropTypes.func,
- tokenSeparators: PropTypes.arrayOf(PropTypes.string),
- notFoundContent: PropTypes.object,
-
- // ControlHeader props
- label: PropTypes.string,
- renderTrigger: PropTypes.bool,
- validationErrors: PropTypes.array,
- rightNode: PropTypes.node,
- leftNode: PropTypes.node,
- onClick: PropTypes.func,
- hovered: PropTypes.bool,
- tooltipOnClick: PropTypes.func,
- warning: PropTypes.string,
- danger: PropTypes.string,
-};
-
const defaultProps = {
autoFocus: false,
choices: [],
@@ -219,8 +169,6 @@ export default class SelectControl extends PureComponent<
SelectControlProps,
SelectControlState
> {
- static propTypes = propTypes;
-
static defaultProps = defaultProps;
constructor(props: SelectControlProps) {
diff --git a/superset-frontend/src/explore/components/controls/TextAreaControl.tsx b/superset-frontend/src/explore/components/controls/TextAreaControl.tsx
index b28f3f0e98f..f8365029ae3 100644
--- a/superset-frontend/src/explore/components/controls/TextAreaControl.tsx
+++ b/superset-frontend/src/explore/components/controls/TextAreaControl.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import { Component } from 'react';
-import PropTypes from 'prop-types';
import { debounce } from 'lodash';
import {
Input,
@@ -81,40 +80,6 @@ interface TextAreaControlProps {
[key: string]: unknown;
}
-const propTypes = {
- name: PropTypes.string,
- onChange: PropTypes.func,
- initialValue: PropTypes.string,
- height: PropTypes.number,
- minLines: PropTypes.number,
- maxLines: PropTypes.number,
- offerEditInModal: PropTypes.bool,
- language: PropTypes.oneOf([
- null,
- 'json',
- 'html',
- 'sql',
- 'markdown',
- 'javascript',
- 'handlebars',
- ]),
- aboveEditorSection: PropTypes.node,
- readOnly: PropTypes.bool,
- resize: PropTypes.oneOf([
- null,
- 'block',
- 'both',
- 'horizontal',
- 'inline',
- 'none',
- 'vertical',
- ]),
- textAreaStyles: PropTypes.object,
- tooltipOptions: PropTypes.object,
- hotkeys: PropTypes.array,
- debounceDelay: PropTypes.number,
-};
-
const defaultProps = {
onChange: () => {},
initialValue: '',
@@ -131,8 +96,6 @@ const defaultProps = {
};
class TextAreaControl extends Component<TextAreaControlProps> {
- static propTypes = propTypes;
-
static defaultProps = defaultProps;
debouncedOnChange:
diff --git a/superset-frontend/src/explore/components/controls/TimeSeriesColumnControl/index.tsx b/superset-frontend/src/explore/components/controls/TimeSeriesColumnControl/index.tsx
index 5a76d4042eb..36aa566aba1 100644
--- a/superset-frontend/src/explore/components/controls/TimeSeriesColumnControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/TimeSeriesColumnControl/index.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import { Component } from 'react';
-import PropTypes from 'prop-types';
import {
Button,
Col,
@@ -70,24 +69,6 @@ interface TimeSeriesColumnControlState {
popoverVisible: boolean;
}
-const propTypes = {
- label: PropTypes.string,
- tooltip: PropTypes.string,
- colType: PropTypes.string,
- width: PropTypes.string,
- height: PropTypes.string,
- timeLag: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- timeRatio: PropTypes.string,
- comparisonType: PropTypes.string,
- showYAxis: PropTypes.bool,
- yAxisBounds: PropTypes.array,
- bounds: PropTypes.array,
- d3format: PropTypes.string,
- dateFormat: PropTypes.string,
- sparkType: PropTypes.string,
- onChange: PropTypes.func,
-};
-
const defaultProps = {
label: t('Time series columns'),
tooltip: '',
@@ -151,8 +132,6 @@ export default class TimeSeriesColumnControl extends Component<
TimeSeriesColumnControlProps,
TimeSeriesColumnControlState
> {
- static propTypes = propTypes;
-
static defaultProps = defaultProps;
constructor(props: TimeSeriesColumnControlProps) {
diff --git a/superset-frontend/src/explore/components/controls/ZoomConfigControl/ZoomConfigControl.tsx b/superset-frontend/src/explore/components/controls/ZoomConfigControl/ZoomConfigControl.tsx
index eedb53298eb..8f0e224fa27 100644
--- a/superset-frontend/src/explore/components/controls/ZoomConfigControl/ZoomConfigControl.tsx
+++ b/superset-frontend/src/explore/components/controls/ZoomConfigControl/ZoomConfigControl.tsx
@@ -195,7 +195,7 @@ export const ZoomConfigControl: FC<ZoomConfigsControlProps> = ({
description={baseWidthDescription}
value={baseWidth}
name="baseWidth"
- // @ts-ignore
+ // @ts-expect-error - Slider onAfterChange type mismatch
onAfterChange={onBaseWidthChange}
step={1}
min={0}
@@ -207,7 +207,7 @@ export const ZoomConfigControl: FC<ZoomConfigsControlProps> = ({
description={baseHeightDescription}
value={baseHeight}
name="baseHeight"
- // @ts-ignore
+ // @ts-expect-error - Slider onAfterChange type mismatch
onAfterChange={onBaseHeightChange}
step={1}
min={0}
@@ -219,7 +219,7 @@ export const ZoomConfigControl: FC<ZoomConfigsControlProps> = ({
description={baseSlopeDescription}
value={baseSlope}
name="slope"
- // @ts-ignore
+ // @ts-expect-error - Slider onAfterChange type mismatch
onAfterChange={onBaseSlopeChange}
disabled={!!(value && !isZoomConfigsLinear(value))}
step={1}
@@ -232,7 +232,7 @@ export const ZoomConfigControl: FC<ZoomConfigsControlProps> = ({
description={baseExponentDescription}
value={baseExponent}
name="exponent"
- // @ts-ignore
+ // @ts-expect-error - Slider onAfterChange type mismatch
onAfterChange={onBaseExponentChange}
disabled={!!(value && !isZoomConfigsExp(value))}
step={0.2}
diff --git a/superset-frontend/src/explore/components/controls/ZoomConfigControl/zoomUtil.test.ts b/superset-frontend/src/explore/components/controls/ZoomConfigControl/zoomUtil.test.ts
index 656c8b9da08..124d4649c30 100644
--- a/superset-frontend/src/explore/components/controls/ZoomConfigControl/zoomUtil.test.ts
+++ b/superset-frontend/src/explore/components/controls/ZoomConfigControl/zoomUtil.test.ts
@@ -185,7 +185,7 @@ describe('zoomUtil', () => {
zoom: 5,
exponent: 1.5,
};
- // @ts-ignore
+ // @ts-expect-error - testing with partial config object
const result = toExpConfig(configs);
test('has correct type', () => {
expect(result.type).toEqual('EXP');
diff --git a/superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.test.ts b/superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.test.ts
index 978a1e07685..8b7bfd91e58 100644
--- a/superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.test.ts
+++ b/superset-frontend/src/explore/exploreUtils/getParsedExploreURLParams.test.ts
@@ -23,7 +23,7 @@ import { getParsedExploreURLParams } from './getParsedExploreURLParams';
const EXPLORE_BASE_URL = 'http://localhost:9000/explore/';
const setupLocation = (newUrl: string) => {
delete (window as any).location;
- // @ts-ignore
+ // @ts-expect-error
window.location = new URL(newUrl);
};
diff --git a/superset-frontend/src/extensions/ExtensionsManager.ts b/superset-frontend/src/extensions/ExtensionsManager.ts
index 55fb1b5eadc..6eb00216119 100644
--- a/superset-frontend/src/extensions/ExtensionsManager.ts
+++ b/superset-frontend/src/extensions/ExtensionsManager.ts
@@ -156,11 +156,11 @@ class ExtensionsManager {
});
// Initialize Webpack module federation
- // @ts-ignore
+ // @ts-expect-error
await __webpack_init_sharing__('default');
const container = (window as any)[id];
- // @ts-ignore
+ // @ts-expect-error
await container.init(__webpack_share_scopes__.default);
const factory = await container.get(exposedModules[0]);
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
index 45d896851ad..ae0d5009843 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
@@ -132,7 +132,7 @@ fetchMock.get(
// Create a valid alert with all required fields entered for validation check
-// @ts-ignore will add id in factory function
+// @ts-expect-error will add id in factory function
const validAlert: AlertObject = {
active: false,
changed_on_delta_humanized: 'now',
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index fddbff73a9d..85548241a4f 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -1887,7 +1887,6 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
: {};
return {
method: setting.type,
- // @ts-ignore: Type not assignable
recipients: config.target || setting.recipient_config_json,
options: allowedNotificationMethods,
cc: config.ccTarget || '',
@@ -1943,7 +1942,6 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
(owner as MetaObject).label ||
`${(owner as Owner).first_name} ${(owner as Owner).last_name}`,
})),
- // @ts-ignore: Type not assignable
validator_config_json:
resource.validator_type === 'not null'
? {
diff --git a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/index.tsx b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/index.tsx
index f33210dc91b..90a2ebeb072 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/index.tsx
+++ b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/index.tsx
@@ -55,7 +55,6 @@ const DatabaseConnectionForm = ({
return (
<Form>
<div
- // @ts-ignore
css={(theme: SupersetTheme) => [
formScrollableStyles,
validatedFormStyles(theme),
@@ -67,7 +66,7 @@ const DatabaseConnectionForm = ({
Object.keys(parameters.properties).includes(key) ||
key === 'database_name',
).map(field =>
- // @ts-ignore TODO: fix ComponentClass for SSHTunnelSwitchComponent not having call signature.
+ // @ts-expect-error TODO: fix ComponentClass for SSHTunnelSwitchComponent not having call signature.
FORM_FIELD_MAP[field]({
required: parameters.required?.includes(field),
changeMethods: {
diff --git a/superset-frontend/src/features/tags/BulkTagModal.tsx b/superset-frontend/src/features/tags/BulkTagModal.tsx
index c183c3cf6e9..70810f94a43 100644
--- a/superset-frontend/src/features/tags/BulkTagModal.tsx
+++ b/superset-frontend/src/features/tags/BulkTagModal.tsx
@@ -128,11 +128,11 @@ const BulkTagModal: FC<BulkTagModalProps> = ({
<FormLabel>{t('tags')}</FormLabel>
<AsyncSelect
ariaLabel="tags"
- // @ts-ignore
+ // @ts-expect-error
value={tags}
options={loadTags}
onHide={onHide}
- // @ts-ignore
+ // @ts-expect-error
onChange={tags => setTags(tags)}
placeholder={t('Select Tags')}
mode="multiple"
diff --git a/superset-frontend/src/features/tags/TagModal.tsx b/superset-frontend/src/features/tags/TagModal.tsx
index 8e5d6467e61..7109f6e3646 100644
--- a/superset-frontend/src/features/tags/TagModal.tsx
+++ b/superset-frontend/src/features/tags/TagModal.tsx
@@ -326,7 +326,7 @@ const TagModal: FC<TagModalProps> = ({
ariaLabel={t('Select dashboards')}
mode="multiple"
name="dashboards"
- // @ts-ignore
+ // @ts-expect-error
value={dashboardsToTag}
options={loadDashboards}
onChange={value =>
@@ -340,7 +340,7 @@ const TagModal: FC<TagModalProps> = ({
ariaLabel={t('Select charts')}
mode="multiple"
name="charts"
- // @ts-ignore
+ // @ts-expect-error
value={chartsToTag}
options={loadCharts}
onChange={value => handleOptionChange(TaggableResources.Chart, value)}
@@ -352,7 +352,7 @@ const TagModal: FC<TagModalProps> = ({
ariaLabel={t('Select saved queries')}
mode="multiple"
name="savedQueries"
- // @ts-ignore
+ // @ts-expect-error
value={savedQueriesToTag}
options={loadQueries}
onChange={value =>
diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.test.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.test.tsx
index d1f22666cad..6843bdbd3e7 100644
--- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.test.tsx
+++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.test.tsx
@@ -21,7 +21,7 @@ import { GenericDataType } from '@apache-superset/core/api/core';
import userEvent from '@testing-library/user-event';
import { render, screen } from 'spec/helpers/testing-library';
import RangeFilterPlugin from './RangeFilterPlugin';
-import { RangeDisplayMode } from './types';
+import { RangeDisplayMode, type PluginFilterRangeProps } from './types';
import { SingleValueType } from './SingleValueType';
import transformProps from './transformProps';
@@ -89,14 +89,12 @@ describe('RangeFilterPlugin', () => {
const setDataMask = jest.fn();
const getWrapper = (props: any = {}) =>
render(
- // @ts-ignore
<RangeFilterPlugin
- // @ts-ignore
- {...transformProps({
+ {...(transformProps({
...rangeProps,
...props,
formData: { ...rangeProps.formData, ...props.formData },
- })}
+ }) as PluginFilterRangeProps)}
setDataMask={setDataMask}
/>,
);
diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
index 2ed450e8f63..e53c3ae27f2 100644
--- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
@@ -232,7 +232,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
} = props;
const [row] = data;
- // @ts-ignore
+ // @ts-expect-error
const { min, max }: { min: number; max: number } = row;
const { groupby, enableSingleValue, enableEmptyFilter, defaultValue } =
formData;
diff --git a/superset-frontend/src/filters/components/Range/buildQuery.ts b/superset-frontend/src/filters/components/Range/buildQuery.ts
index 7f4ad6cc987..cdbebeccc8e 100644
--- a/superset-frontend/src/filters/components/Range/buildQuery.ts
+++ b/superset-frontend/src/filters/components/Range/buildQuery.ts
@@ -36,7 +36,7 @@ import { GenericDataType } from '@apache-superset/core/api/core';
export default function buildQuery(formData: QueryFormData) {
const { groupby } = formData;
const [column = ''] = groupby || [];
- // @ts-ignore (need update interface Column )
+ // @ts-expect-error (need update interface Column )
return buildQueryContext(formData, baseQueryObject => [
{
...baseQueryObject,
diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
index b2118533484..2427047908d 100644
--- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
+++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
@@ -79,9 +79,9 @@ describe('SelectFilterPlugin', () => {
const setDataMask = jest.fn();
const getWrapper = (props = {}) =>
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps({
...selectMultipleProps,
formData: { ...selectMultipleProps.formData, ...props },
@@ -297,9 +297,9 @@ describe('SelectFilterPlugin', () => {
test('Select big int value', async () => {
const bigValue = 1100924931345932234n;
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps({
...selectMultipleProps,
formData: { ...selectMultipleProps.formData, groupby: 'bval' },
@@ -417,9 +417,9 @@ describe('SelectFilterPlugin', () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={jest.fn()}
showOverflow={false}
@@ -491,9 +491,9 @@ describe('SelectFilterPlugin', () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={jest.fn()}
showOverflow={false}
@@ -565,9 +565,9 @@ describe('SelectFilterPlugin', () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={jest.fn()}
showOverflow={false}
@@ -639,9 +639,9 @@ describe('SelectFilterPlugin', () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={jest.fn()}
showOverflow={false}
@@ -704,9 +704,9 @@ test('Select boolean FALSE value in single-select mode', async () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={setDataMaskMock}
showOverflow={false}
@@ -781,9 +781,9 @@ test('Select boolean TRUE value in single-select mode', async () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={setDataMaskMock}
showOverflow={false}
@@ -858,9 +858,9 @@ test('Select both boolean values in multi-select mode', async () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={setDataMaskMock}
showOverflow={false}
@@ -935,9 +935,9 @@ test('Select boolean filter with null values', async () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={setDataMaskMock}
showOverflow={false}
@@ -1013,9 +1013,9 @@ test('Clear boolean FALSE value', async () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={setDataMaskMock}
showOverflow={false}
@@ -1084,9 +1084,9 @@ test('Clear boolean TRUE value', async () => {
};
render(
- // @ts-ignore
+ // @ts-expect-error
<SelectFilterPlugin
- // @ts-ignore
+ // @ts-expect-error
{...transformProps(testProps)}
setDataMask={setDataMaskMock}
showOverflow={false}
diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
index d70fd7c90fe..8f94817b481 100644
--- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
@@ -531,7 +531,7 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
onFocus={setFocusedFilter}
onMouseEnter={setHoveredFilter}
onMouseLeave={unsetHoveredFilter}
- // @ts-ignore
+ // @ts-expect-error
onChange={handleChange}
ref={inputRef}
loading={isRefreshing}
diff --git a/superset-frontend/src/filters/components/TimeColumn/TimeColumnFilterPlugin.tsx b/superset-frontend/src/filters/components/TimeColumn/TimeColumnFilterPlugin.tsx
index 6faf49f1171..7377816429e 100644
--- a/superset-frontend/src/filters/components/TimeColumn/TimeColumnFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/TimeColumn/TimeColumnFilterPlugin.tsx
@@ -111,7 +111,7 @@ export default function PluginFilterTimeColumn(
allowClear
value={value}
placeholder={placeholderText}
- // @ts-ignore
+ // @ts-expect-error
onChange={handleChange}
onBlur={unsetFocusedFilter}
onFocus={setFocusedFilter}
diff --git a/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx b/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx
index 3c65cbc4b63..1a376b1e9e8 100644
--- a/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx
@@ -125,7 +125,7 @@ export default function PluginFilterTimegrain(
allowClear
value={value}
placeholder={placeholderText}
- // @ts-ignore
+ // @ts-expect-error
onChange={handleChange}
onBlur={unsetFocusedFilter}
onFocus={setFocusedFilter}
diff --git a/superset-frontend/src/filters/utils.ts b/superset-frontend/src/filters/utils.ts
index 30981aa5e76..038fee7d16e 100644
--- a/superset-frontend/src/filters/utils.ts
+++ b/superset-frontend/src/filters/utils.ts
@@ -50,7 +50,6 @@ export const getSelectExtraFormData = (
{
col,
op: shouldExcludeFilter ? ('NOT IN' as const) : ('IN' as const),
- // @ts-ignore
val: value,
},
];
diff --git a/superset-frontend/src/pages/AlertReportList/AlertReportList.test.tsx b/superset-frontend/src/pages/AlertReportList/AlertReportList.test.tsx
index 22e97511b90..588478791ad 100644
--- a/superset-frontend/src/pages/AlertReportList/AlertReportList.test.tsx
+++ b/superset-frontend/src/pages/AlertReportList/AlertReportList.test.tsx
@@ -27,6 +27,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import React from 'react';
import AlertListComponent from 'src/pages/AlertReportList';
@@ -92,7 +93,7 @@ fetchMock.delete(alertsEndpoint, {});
const renderAlertList = (props = {}) =>
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<AlertList user={mockUser} {...props} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/AnnotationLayerList/AnnotationLayerList.test.tsx b/superset-frontend/src/pages/AnnotationLayerList/AnnotationLayerList.test.tsx
index b2fb9fd7b1d..b8260d3ff3f 100644
--- a/superset-frontend/src/pages/AnnotationLayerList/AnnotationLayerList.test.tsx
+++ b/superset-frontend/src/pages/AnnotationLayerList/AnnotationLayerList.test.tsx
@@ -27,6 +27,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import React from 'react';
import AnnotationLayersListComponent from 'src/pages/AnnotationLayerList';
@@ -81,7 +82,7 @@ fetchMock.get(layersRelatedEndpoint, {
const renderAnnotationLayersList = (props = {}) =>
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<AnnotationLayersList user={mockUser} {...props} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/ChartList/ChartList.permissions.test.tsx b/superset-frontend/src/pages/ChartList/ChartList.permissions.test.tsx
index 5406f7b4caf..38db8180d20 100644
--- a/superset-frontend/src/pages/ChartList/ChartList.permissions.test.tsx
+++ b/superset-frontend/src/pages/ChartList/ChartList.permissions.test.tsx
@@ -22,6 +22,7 @@ import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import { configureStore } from '@reduxjs/toolkit';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import { isFeatureEnabled } from '@superset-ui/core';
import ChartList from 'src/pages/ChartList';
import { API_ENDPOINTS, mockCharts, setupMocks } from './ChartList.testHelpers';
@@ -116,7 +117,7 @@ const renderChartList = (
return render(
<Provider store={store}>
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<ChartList user={user} {...props} />
</QueryParamProvider>
</MemoryRouter>
diff --git a/superset-frontend/src/pages/ChartList/ChartList.testHelpers.tsx b/superset-frontend/src/pages/ChartList/ChartList.testHelpers.tsx
index d6518a0a4df..c92b92c8bbf 100644
--- a/superset-frontend/src/pages/ChartList/ChartList.testHelpers.tsx
+++ b/superset-frontend/src/pages/ChartList/ChartList.testHelpers.tsx
@@ -23,6 +23,7 @@ import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import { configureStore } from '@reduxjs/toolkit';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import ChartList from 'src/pages/ChartList';
import handleResourceExport from 'src/utils/export';
@@ -269,7 +270,7 @@ export const renderChartList = (user: any, props = {}, storeState = {}) => {
return render(
<Provider store={store}>
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<ChartList user={user} {...props} />
</QueryParamProvider>
</MemoryRouter>
diff --git a/superset-frontend/src/pages/CssTemplateList/CssTemplateList.test.tsx b/superset-frontend/src/pages/CssTemplateList/CssTemplateList.test.tsx
index c636b45027d..418c2da1216 100644
--- a/superset-frontend/src/pages/CssTemplateList/CssTemplateList.test.tsx
+++ b/superset-frontend/src/pages/CssTemplateList/CssTemplateList.test.tsx
@@ -27,6 +27,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import React from 'react';
import CssTemplatesListComponent from 'src/pages/CssTemplateList';
@@ -81,7 +82,7 @@ fetchMock.get(templatesRelatedEndpoint, {
const renderCssTemplatesList = (props = {}) =>
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<CssTemplatesList user={mockUser} {...props} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/DashboardList/DashboardList.test.tsx b/superset-frontend/src/pages/DashboardList/DashboardList.test.tsx
index dbc7a13a69a..a5545b499ba 100644
--- a/superset-frontend/src/pages/DashboardList/DashboardList.test.tsx
+++ b/superset-frontend/src/pages/DashboardList/DashboardList.test.tsx
@@ -27,6 +27,7 @@ import {
fireEvent,
} from 'spec/helpers/testing-library';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import DashboardListComponent from 'src/pages/DashboardList';
@@ -95,7 +96,7 @@ describe('DashboardList', () => {
const renderDashboardList = (props = {}, userProp = mockUser) =>
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<DashboardList {...props} user={userProp} />
</QueryParamProvider>
</MemoryRouter>,
@@ -231,7 +232,7 @@ describe('DashboardList - anonymous view', () => {
test('does not render favorite stars for anonymous user', async () => {
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<DashboardList user={{}} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/GroupsList/GroupsList.test.tsx b/superset-frontend/src/pages/GroupsList/GroupsList.test.tsx
index 4acb6c21d47..399409cee9f 100644
--- a/superset-frontend/src/pages/GroupsList/GroupsList.test.tsx
+++ b/superset-frontend/src/pages/GroupsList/GroupsList.test.tsx
@@ -30,6 +30,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import GroupsList from './index';
const mockStore = configureStore([thunk]);
@@ -79,7 +80,7 @@ describe('GroupsList', () => {
await act(async () => {
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<GroupsList user={mockUser} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/Home/Home.test.tsx b/superset-frontend/src/pages/Home/Home.test.tsx
index fcdf94a36a4..57350cb8522 100644
--- a/superset-frontend/src/pages/Home/Home.test.tsx
+++ b/superset-frontend/src/pages/Home/Home.test.tsx
@@ -199,20 +199,20 @@ test('Without sql role - renders', async () => {
/*
We ignore the ts error here because the type does not recognize the absence of a role entry
*/
- // @ts-ignore-next-line
+ // @ts-expect-error-next-line
await renderWelcome(mockedPropsWithoutSqlRole);
expect(await screen.findByText('Dashboards')).toBeInTheDocument();
});
test('Without sql role - renders all panels on the page on page load', async () => {
- // @ts-ignore-next-line
+ // @ts-expect-error-next-line
await renderWelcome(mockedPropsWithoutSqlRole);
const panels = await screen.findAllByText(/Dashboards|Charts|Recents/);
expect(panels).toHaveLength(3);
});
test('Without sql role - calls api methods in parallel on page load', async () => {
- // @ts-ignore-next-line
+ // @ts-expect-error-next-line
await renderWelcome(mockedPropsWithoutSqlRole);
expect(fetchMock.callHistory.calls(chartsEndpoint)).toHaveLength(2);
expect(fetchMock.callHistory.calls(recentActivityEndpoint)).toHaveLength(1);
diff --git a/superset-frontend/src/pages/RolesList/RolesList.test.tsx b/superset-frontend/src/pages/RolesList/RolesList.test.tsx
index eca699352ed..056491fbadd 100644
--- a/superset-frontend/src/pages/RolesList/RolesList.test.tsx
+++ b/superset-frontend/src/pages/RolesList/RolesList.test.tsx
@@ -29,6 +29,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import RolesList from './index';
const mockStore = configureStore([thunk]);
@@ -107,7 +108,7 @@ describe('RolesList', () => {
const mockedProps = {};
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<RolesList
user={mockUser}
addDangerToast={() => {}}
diff --git a/superset-frontend/src/pages/RowLevelSecurityList/RowLevelSecurityList.test.tsx b/superset-frontend/src/pages/RowLevelSecurityList/RowLevelSecurityList.test.tsx
index f68c44d03d8..b23b2421461 100644
--- a/superset-frontend/src/pages/RowLevelSecurityList/RowLevelSecurityList.test.tsx
+++ b/superset-frontend/src/pages/RowLevelSecurityList/RowLevelSecurityList.test.tsx
@@ -20,6 +20,7 @@ import fetchMock from 'fetch-mock';
import { act, render, screen, within } from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import userEvent from '@testing-library/user-event';
import RowLevelSecurityList from '.';
@@ -109,7 +110,7 @@ describe('RuleList RTL', () => {
const mockedProps = {};
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<RowLevelSecurityList {...mockedProps} user={mockUser} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/SavedQueryList/SavedQueryList.test.tsx b/superset-frontend/src/pages/SavedQueryList/SavedQueryList.test.tsx
index dc89f50fc14..9758154b292 100644
--- a/superset-frontend/src/pages/SavedQueryList/SavedQueryList.test.tsx
+++ b/superset-frontend/src/pages/SavedQueryList/SavedQueryList.test.tsx
@@ -27,6 +27,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import SavedQueryList from '.';
// Increase default timeout
@@ -85,7 +86,7 @@ fetchMock.delete(queryEndpoint, {}, { name: queryEndpoint });
const renderList = (props = {}, storeOverrides = {}) =>
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<SavedQueryList user={mockUser} {...props} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/UserInfo/UserInfo.test.tsx b/superset-frontend/src/pages/UserInfo/UserInfo.test.tsx
index e12ce245b4e..f445d998a27 100644
--- a/superset-frontend/src/pages/UserInfo/UserInfo.test.tsx
+++ b/superset-frontend/src/pages/UserInfo/UserInfo.test.tsx
@@ -28,6 +28,7 @@ import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import UserInfo from 'src/pages/UserInfo';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
@@ -64,7 +65,7 @@ describe('UserInfo', () => {
act(async () => {
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<UserInfo user={mockUser} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/pages/UsersList/UsersList.test.tsx b/superset-frontend/src/pages/UsersList/UsersList.test.tsx
index 62ff7ff4756..465a0c531fc 100644
--- a/superset-frontend/src/pages/UsersList/UsersList.test.tsx
+++ b/superset-frontend/src/pages/UsersList/UsersList.test.tsx
@@ -29,6 +29,7 @@ import {
} from 'spec/helpers/testing-library';
import { MemoryRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import UsersList from './index';
const mockStore = configureStore([thunk]);
@@ -100,7 +101,7 @@ describe('UsersList', () => {
const mockedProps = {};
render(
<MemoryRouter>
- <QueryParamProvider>
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<UsersList user={mockUser} {...mockedProps} />
</QueryParamProvider>
</MemoryRouter>,
diff --git a/superset-frontend/src/setup/setupColors.ts b/superset-frontend/src/setup/setupColors.ts
index 140bf79b423..ee1ab048854 100644
--- a/superset-frontend/src/setup/setupColors.ts
+++ b/superset-frontend/src/setup/setupColors.ts
@@ -69,7 +69,6 @@ export default function setupColors(
config => new SequentialScheme(config),
);
registerColorSchemes(
- // @ts-ignore
getCategoricalSchemeRegistry(),
[
...CategoricalAirbnb,
@@ -90,7 +89,6 @@ export default function setupColors(
'supersetColors',
);
registerColorSchemes(
- // @ts-ignore
getSequentialSchemeRegistry(),
[...SequentialCommon, ...SequentialD3, ...extraSequentialColorSchemes],
'superset_seq_1',
diff --git a/superset-frontend/src/views/CRUD/utils.tsx b/superset-frontend/src/views/CRUD/utils.tsx
index 976d947df83..4f29f67223b 100644
--- a/superset-frontend/src/views/CRUD/utils.tsx
+++ b/superset-frontend/src/views/CRUD/utils.tsx
@@ -248,7 +248,6 @@ export function createErrorHandler(
return async (e: SupersetClientResponse | string) => {
const parsedError = await getClientErrorObject(e);
// Taking the first error returned from the API
- // @ts-ignore
const errorsArray = parsedError?.errors;
const config = await SupersetText;
if (
diff --git a/superset-frontend/src/views/RootContextProviders.tsx b/superset-frontend/src/views/RootContextProviders.tsx
index c10f04ae816..71afb8a8fa5 100644
--- a/superset-frontend/src/views/RootContextProviders.tsx
+++ b/superset-frontend/src/views/RootContextProviders.tsx
@@ -17,10 +17,10 @@
* under the License.
*/
-import { Route } from 'react-router-dom';
import { getExtensionsRegistry } from '@superset-ui/core';
import { Provider as ReduxProvider } from 'react-redux';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { DynamicPluginProvider } from 'src/components';
@@ -45,10 +45,7 @@ export const RootContextProviders: React.FC = ({ children }) => {
<DndProvider backend={HTML5Backend}>
<EmbeddedUiConfigProvider>
<DynamicPluginProvider>
- <QueryParamProvider
- ReactRouterRoute={Route}
- stringifyOptions={{ encode: false }}
- >
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<ExtensionsProvider>
{RootContextProviderExtension ? (
<RootContextProviderExtension>
diff --git a/superset-frontend/src/views/menu.tsx b/superset-frontend/src/views/menu.tsx
index fd72529bee2..c9ea707375a 100644
--- a/superset-frontend/src/views/menu.tsx
+++ b/superset-frontend/src/views/menu.tsx
@@ -22,9 +22,10 @@ import 'src/public-path';
// eg, backend rendered views
import { Provider } from 'react-redux';
import ReactDOM from 'react-dom';
-import { Route, BrowserRouter } from 'react-router-dom';
+import { BrowserRouter } from 'react-router-dom';
import { CacheProvider } from '@emotion/react';
import { QueryParamProvider } from 'use-query-params';
+import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import createCache from '@emotion/cache';
import { ThemeProvider, theme } from '@apache-superset/core/ui';
import Menu from 'src/features/home/Menu';
@@ -42,15 +43,11 @@ const emotionCache = createCache({
});
const app = (
- // @ts-ignore: emotion types defs are incompatible between core and cache
<CacheProvider value={emotionCache}>
<ThemeProvider theme={theme}>
<Provider store={store}>
<BrowserRouter>
- <QueryParamProvider
- ReactRouterRoute={Route}
- stringifyOptions={{ encode: false }}
- >
+ <QueryParamProvider adapter={ReactRouter5Adapter}>
<Menu data={menu} />
</QueryParamProvider>
</BrowserRouter>
diff --git a/superset-frontend/tsconfig.json b/superset-frontend/tsconfig.json
index 3d66ec75be5..79deccc24e7 100644
--- a/superset-frontend/tsconfig.json
+++ b/superset-frontend/tsconfig.json
@@ -28,6 +28,7 @@
/* Interop Constraints */
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
+ "resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
/* Language and Environment */
diff --git a/superset-frontend/webpack.config.js b/superset-frontend/webpack.config.js
index 4b643de595e..14e9171aa6b 100644
--- a/superset-frontend/webpack.config.js
+++ b/superset-frontend/webpack.config.js
@@ -188,7 +188,7 @@ if (isDevMode) {
}
if (!isDevMode) {
- // text loading (webpack 4+)
+ // CSS extraction for production builds
plugins.push(
new MiniCssExtractPlugin({
filename: '[name].[chunkhash].entry.css',
@@ -226,7 +226,7 @@ if (isDevMode) {
// otherwise the websocket client will initialize twice, creating two sockets.
// Ref: https://github.com/gaearon/react-hot-loader/issues/141
PREAMBLE.unshift(
- `webpack-dev-server/client?http://localhost:${devserverPort}`,
+ `webpack-dev-server/client?http://${devserverHost}:${devserverPort}`,
);
}
@@ -305,7 +305,11 @@ const config = {
type: 'filesystem', // Enable filesystem caching
cacheDirectory: path.resolve(__dirname, '.temp_cache'),
buildDependencies: {
- config: [__filename],
+ config: [
+ __filename,
+ path.resolve(__dirname, 'tsconfig.json'),
+ path.resolve(__dirname, 'babel.config.js'),
+ ],
},
},
output,
@@ -431,8 +435,9 @@ const config = {
This prevents "Module not found" errors for moment locale files.
*/
'moment/min/moment-with-locales': false,
- // Temporary workaround to allow Storybook 8 to work with existing React v16-compatible stories.
- // Remove below alias once React has been upgreade to v18.
+ // Storybook 8 expects React 18's createRoot API. Since this project uses React 17,
+ // we alias to the react-16 shim which provides the legacy ReactDOM.render API.
+ // Remove this alias when React is upgraded to v18+.
'@storybook/react-dom-shim': path.resolve(
path.join(
APP_DIR,