diff --git a/.dumi/theme/builtins/DemoWrapper/index.tsx b/.dumi/theme/builtins/DemoWrapper/index.tsx index f5b75efe95..ebcafc24fe 100644 --- a/.dumi/theme/builtins/DemoWrapper/index.tsx +++ b/.dumi/theme/builtins/DemoWrapper/index.tsx @@ -51,32 +51,27 @@ const DemoWrapper: typeof DumiDemoGrid = ({ items }) => { const demos = React.useMemo( () => - items.reduce( - (acc, item) => { - const { previewerProps } = item; - const { debug } = previewerProps; - - if (debug && !showDebug) { - return acc; - } - - return acc.concat({ - ...item, - previewerProps: { - ...previewerProps, - expand: expandAll, - // always override debug property, because dumi will hide debug demo in production - debug: false, - /** - * antd extra marker for the original debug - * @see https://github.com/ant-design/ant-design/pull/40130#issuecomment-1380208762 - */ - originDebug: debug, - }, - }); - }, - [] as typeof items, - ), + items.reduce((acc, item) => { + const { previewerProps } = item; + const { debug } = previewerProps; + if (debug && !showDebug) { + return acc; + } + return acc.concat({ + ...item, + previewerProps: { + ...previewerProps, + expand: expandAll, + // always override debug property, because dumi will hide debug demo in production + debug: false, + /** + * antd extra marker for the original debug + * @see https://github.com/ant-design/ant-design/pull/40130#issuecomment-1380208762 + */ + originDebug: debug, + }, + }); + }, []), [expandAll, showDebug], ); diff --git a/components/modal/locale.ts b/components/modal/locale.ts index 46acfbce93..9cca1460c9 100644 --- a/components/modal/locale.ts +++ b/components/modal/locale.ts @@ -13,9 +13,9 @@ let runtimeLocale: ModalLocale = { let localeList: ModalLocale[] = []; const generateLocale = () => - localeList.reduce( + localeList.reduce( (merged, locale) => ({ ...merged, ...locale }), - defaultLocale.Modal as ModalLocale, + defaultLocale.Modal!, ); export function changeConfirmLocale(newLocale?: ModalLocale) { diff --git a/components/tabs/demo/extra.tsx b/components/tabs/demo/extra.tsx index b88d1e98d5..0e13bd5159 100644 --- a/components/tabs/demo/extra.tsx +++ b/components/tabs/demo/extra.tsx @@ -27,8 +27,9 @@ const App: React.FC = () => { const [position, setPosition] = useState(['left', 'right']); const slot = useMemo(() => { - if (position.length === 0) return null; - + if (position.length === 0) { + return null; + } return position.reduce( (acc, direction) => ({ ...acc, [direction]: OperationsSlot[direction] }), {}, diff --git a/components/theme/themes/dark/index.ts b/components/theme/themes/dark/index.ts index a81202e0e0..03a90cf842 100644 --- a/components/theme/themes/dark/index.ts +++ b/components/theme/themes/dark/index.ts @@ -1,13 +1,7 @@ import { generate } from '@ant-design/colors'; import type { DerivativeFunc } from '@ant-design/cssinjs'; -import type { - ColorPalettes, - LegacyColorPalettes, - MapToken, - PresetColorType, - SeedToken, -} from '../../interface'; +import type { MapToken, PresetColorType, SeedToken } from '../../interface'; import defaultAlgorithm from '../default'; import { defaultPresetColors } from '../seed'; import genColorMapToken from '../shared/genColorMapToken'; @@ -17,24 +11,17 @@ const derivative: DerivativeFunc = (token, mapToken) => { const colorPalettes = Object.keys(defaultPresetColors) .map((colorKey) => { const colors = generate(token[colorKey as keyof PresetColorType], { theme: 'dark' }); - return new Array(10).fill(1).reduce((prev, _, i) => { prev[`${colorKey}-${i + 1}`] = colors[i]; prev[`${colorKey}${i + 1}`] = colors[i]; return prev; - }, {}) as ColorPalettes & LegacyColorPalettes; + }, {}); }) - .reduce( - (prev, cur) => { - // biome-ignore lint/style/noParameterAssign: it is a reduce - prev = { - ...prev, - ...cur, - }; - return prev; - }, - {} as ColorPalettes & LegacyColorPalettes, - ); + .reduce((prev, cur) => { + // biome-ignore lint/style/noParameterAssign: it is a reduce + prev = { ...prev, ...cur }; + return prev; + }, {}); const mergedMapToken = mapToken ?? defaultAlgorithm(token); diff --git a/components/theme/themes/default/index.ts b/components/theme/themes/default/index.ts index f5a11ace3e..c65e5f4b2a 100644 --- a/components/theme/themes/default/index.ts +++ b/components/theme/themes/default/index.ts @@ -1,12 +1,6 @@ import { generate } from '@ant-design/colors'; -import type { - ColorPalettes, - LegacyColorPalettes, - MapToken, - PresetColorType, - SeedToken, -} from '../../interface'; +import type { MapToken, PresetColorType, SeedToken } from '../../interface'; import { defaultPresetColors } from '../seed'; import genColorMapToken from '../shared/genColorMapToken'; import genCommonMapToken from '../shared/genCommonMapToken'; @@ -19,24 +13,17 @@ export default function derivative(token: SeedToken): MapToken { const colorPalettes = Object.keys(defaultPresetColors) .map((colorKey) => { const colors = generate(token[colorKey as keyof PresetColorType]); - return new Array(10).fill(1).reduce((prev, _, i) => { prev[`${colorKey}-${i + 1}`] = colors[i]; prev[`${colorKey}${i + 1}`] = colors[i]; return prev; - }, {}) as ColorPalettes & LegacyColorPalettes; + }, {}); }) - .reduce( - (prev, cur) => { - // biome-ignore lint/style/noParameterAssign: it is a reduce - prev = { - ...prev, - ...cur, - }; - return prev; - }, - {} as ColorPalettes & LegacyColorPalettes, - ); + .reduce((prev, cur) => { + // biome-ignore lint/style/noParameterAssign: it is a reduce + prev = { ...prev, ...cur }; + return prev; + }, {}); return { ...token, diff --git a/components/theme/util/genPresetColor.ts b/components/theme/util/genPresetColor.ts index b4d96116b0..11e8ab6769 100644 --- a/components/theme/util/genPresetColor.ts +++ b/components/theme/util/genPresetColor.ts @@ -22,15 +22,14 @@ export default function genPresetColor { + return PresetColors.reduce((prev: CSSObject, colorKey: PresetColorKey) => { const lightColor = token[`${colorKey}1`]; const lightBorderColor = token[`${colorKey}3`]; const darkColor = token[`${colorKey}6`]; const textColor = token[`${colorKey}7`]; - return { ...prev, ...genCss(colorKey, { lightColor, lightBorderColor, darkColor, textColor }), }; - }, {} as CSSObject); + }, {}); } diff --git a/scripts/generate-token-meta.ts b/scripts/generate-token-meta.ts index ae864c85b3..286eb86b58 100644 --- a/scripts/generate-token-meta.ts +++ b/scripts/generate-token-meta.ts @@ -107,7 +107,7 @@ const main = async () => { } }); - const finalMeta = Object.entries(tokenMeta).reduce((acc, [key, value]) => { + const finalMeta = Object.entries(tokenMeta).reduce((acc, [key, value]) => { if (key !== 'components') { (value as any[]).forEach((item) => { acc.global = acc.global || {}; @@ -124,7 +124,7 @@ const main = async () => { acc.components = value; } return acc; - }, {} as any); + }, {}); fs.writeJsonSync(output, finalMeta, 'utf8'); // eslint-disable-next-line no-console