mirror of
https://github.com/apache/superset.git
synced 2026-05-07 17:04:58 +00:00
fix: resolve TypeScript errors in migrated files
- common.ts: wrap return in Boolean() for proper boolean type - logger.test.ts: add dispatch property to MockStore interface - exploreReducer.ts: use flexible ExtendedControlState interface, fix SliceUpdatedAction owners type - ReportModal/actions.ts: use ThunkDispatch for thunk actions, add error handling to addReport - ReportModal/reducer.ts: cast through unknown for dynamic property access Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -144,7 +144,7 @@ interface SetStashFormDataAction {
|
||||
|
||||
interface SliceUpdatedAction {
|
||||
type: typeof actions.SLICE_UPDATED;
|
||||
slice: Slice & {
|
||||
slice: Omit<Slice, 'owners'> & {
|
||||
owners?: Array<{ value: number; label: string }>;
|
||||
slice_name?: string;
|
||||
};
|
||||
@@ -175,7 +175,11 @@ type ExploreAction =
|
||||
| SetForceQueryAction
|
||||
| HydrateExplore;
|
||||
|
||||
interface ExtendedControlState extends ControlState {
|
||||
// Extended control state for dynamic form controls - uses Record for flexibility
|
||||
// since control configs vary significantly across different control types
|
||||
interface ExtendedControlState {
|
||||
[key: string]: unknown;
|
||||
value?: unknown;
|
||||
valueKey?: string;
|
||||
savedMetrics?: unknown[];
|
||||
columns?: unknown[];
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
} from 'src/components/MessageToasts/actions';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { Dispatch, AnyAction } from 'redux';
|
||||
import { ThunkDispatch } from 'redux-thunk';
|
||||
import { ReportObject, ReportCreationMethod } from 'src/features/reports/types';
|
||||
import { DashboardInfo, ChartsState } from 'src/dashboard/types';
|
||||
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
|
||||
@@ -130,7 +131,7 @@ export function fetchUISpecificReport({
|
||||
}
|
||||
|
||||
const structureFetchAction = (
|
||||
dispatch: Dispatch<AnyAction>,
|
||||
dispatch: ThunkDispatch<ReportRootState, unknown, AnyAction>,
|
||||
getState: () => ReportRootState,
|
||||
) => {
|
||||
const state = getState();
|
||||
@@ -169,10 +170,14 @@ export const addReport =
|
||||
SupersetClient.post({
|
||||
endpoint: `/api/v1/report/`,
|
||||
jsonPayload: report,
|
||||
}).then(({ json }) => {
|
||||
dispatch({ type: ADD_REPORT, json } as AddReportAction);
|
||||
dispatch(addSuccessToast(t('The report has been created')));
|
||||
});
|
||||
})
|
||||
.then(({ json }) => {
|
||||
dispatch({ type: ADD_REPORT, json } as AddReportAction);
|
||||
dispatch(addSuccessToast(t('The report has been created')));
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(addDangerToast(t('Failed to create report')));
|
||||
});
|
||||
|
||||
export const EDIT_REPORT = 'EDIT_REPORT' as const;
|
||||
|
||||
@@ -193,7 +198,9 @@ export const editReport =
|
||||
});
|
||||
|
||||
export function toggleActive(report: ReportObject, isActive: boolean) {
|
||||
return function toggleActiveThunk(dispatch: Dispatch<AnyAction>) {
|
||||
return function toggleActiveThunk(
|
||||
dispatch: ThunkDispatch<ReportRootState, unknown, AnyAction>,
|
||||
) {
|
||||
return SupersetClient.put({
|
||||
endpoint: encodeURI(`/api/v1/report/${report.id}`),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function reportsReducer(
|
||||
// functionality changes.
|
||||
const reportObject = report.result?.find(
|
||||
(r: ReportObject) =>
|
||||
(r as Record<string, number>)[filterField] === resourceId,
|
||||
(r as unknown as Record<string, number>)[filterField] === resourceId,
|
||||
);
|
||||
|
||||
if (reportObject) {
|
||||
|
||||
@@ -31,6 +31,7 @@ interface MockStore {
|
||||
dashboardInfo: { id: number };
|
||||
impressionId: string;
|
||||
};
|
||||
dispatch: () => void;
|
||||
}
|
||||
|
||||
interface LogEventAction {
|
||||
@@ -52,6 +53,7 @@ describe('logger middleware', () => {
|
||||
},
|
||||
impressionId: 'impression_id',
|
||||
}),
|
||||
dispatch: () => {},
|
||||
};
|
||||
const action: LogEventAction = {
|
||||
type: LOG_EVENT,
|
||||
|
||||
@@ -173,5 +173,5 @@ export const detectOS = (): OSType => {
|
||||
export const isSafari = (): boolean => {
|
||||
const { userAgent } = navigator;
|
||||
|
||||
return userAgent && /^((?!chrome|android).)*safari/i.test(userAgent);
|
||||
return Boolean(userAgent && /^((?!chrome|android).)*safari/i.test(userAgent));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user