feat(fe): upgrade superset-frontend to Typescript v5 (#31979)

Signed-off-by: hainenber <dotronghai96@gmail.com>
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
Đỗ Trọng Hải
2025-01-29 18:40:33 +07:00
committed by GitHub
parent a21f184058
commit 19e8a7049b
141 changed files with 1095 additions and 572 deletions

View File

@@ -165,7 +165,8 @@ export default function transformProps(chartProps: ChartProps) {
percentDifferenceNum = (bigNumber - prevNumber) / Math.abs(prevNumber);
}
const compType = compTitles[formData.timeComparison];
const compType =
compTitles[formData.timeComparison as keyof typeof compTitles];
bigNumber = numberFormatter(bigNumber);
prevNumber = numberFormatter(prevNumber);
valueDifference = numberFormatter(valueDifference);

View File

@@ -35,7 +35,7 @@ const getFontSizeMapping = (
proportionValues: number[],
actualSizes: number[],
) =>
proportionValues.reduce((acc, value, index) => {
proportionValues.reduce<Record<number, number>>((acc, value, index) => {
acc[value] = actualSizes[index] ?? actualSizes[actualSizes.length - 1];
return acc;
}, {});

View File

@@ -112,12 +112,15 @@ export default {
Array.isArray(colnames) && Array.isArray(coltypes)
? colnames
.filter(
(colname: string, index: number) =>
(_: string, index: number) =>
coltypes[index] === GenericDataType.Numeric,
)
.map(colname => ({
.map((colname: string | number) => ({
value: colname,
label: verboseMap[colname] ?? colname,
label:
(Array.isArray(verboseMap)
? verboseMap[colname as number]
: verboseMap[colname as string]) ?? colname,
}))
: [];
return {

View File

@@ -38,18 +38,37 @@ import { getPadding } from '../Timeseries/transformers';
import { convertInteger } from '../utils/convertInteger';
import { NULL_STRING } from '../constants';
const isIterable = (obj: any): obj is Iterable<any> =>
obj != null && typeof obj[Symbol.iterator] === 'function';
function normalizeSymbolSize(
nodes: ScatterSeriesOption[],
maxBubbleValue: number,
) {
const [bubbleMinValue, bubbleMaxValue] = extent(nodes, x => x.data?.[0]?.[2]);
const nodeSpread = bubbleMaxValue - bubbleMinValue;
nodes.forEach(node => {
// eslint-disable-next-line no-param-reassign
node.symbolSize =
(((node.data?.[0]?.[2] - bubbleMinValue) / nodeSpread) *
(maxBubbleValue * 2) || 0) + MINIMUM_BUBBLE_SIZE;
});
const [bubbleMinValue, bubbleMaxValue] = extent<ScatterSeriesOption, number>(
nodes,
x => {
const tmpValue = x.data?.[0];
const result = isIterable(tmpValue) ? tmpValue[2] : null;
if (typeof result === 'number') {
return result;
}
return null;
},
);
if (bubbleMinValue !== undefined && bubbleMaxValue !== undefined) {
const nodeSpread = bubbleMaxValue - bubbleMinValue;
nodes.forEach(node => {
const tmpValue = node.data?.[0];
const calculated = isIterable(tmpValue) ? tmpValue[2] : null;
if (typeof calculated === 'number') {
// eslint-disable-next-line no-param-reassign
node.symbolSize =
(((calculated - bubbleMinValue) / nodeSpread) *
(maxBubbleValue * 2) || 0) + MINIMUM_BUBBLE_SIZE;
}
});
}
}
export function formatTooltip(

View File

@@ -518,7 +518,9 @@ export default function transformProps(
minorTick: { show: minorTicks },
minInterval:
xAxisType === AxisType.Time && timeGrainSqla
? TIMEGRAIN_TO_TIMESTAMP[timeGrainSqla]
? TIMEGRAIN_TO_TIMESTAMP[
timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
]
: 0,
...getMinAndMaxFromBounds(
xAxisType,

View File

@@ -29,7 +29,7 @@ export const retainFormDataSuffix = (
* > removeFormDataSuffix(fd, '_b')
* { metrics: ['zee'], limit: 100, ... }
* */
const newFormData = {};
const newFormData: Record<string, any> = {};
Object.entries(formData)
.sort(([a], [b]) => {
@@ -63,7 +63,7 @@ export const removeFormDataSuffix = (
* > removeUnusedFormData(fd, '_b')
* { metrics: ['foo', 'bar'], limit: 100, ... }
* */
const newFormData = {};
const newFormData: Record<string, any> = {};
Object.entries(formData).forEach(([key, value]) => {
if (!key.endsWith(controlSuffix)) {
newFormData[key] = value;