Browse Source

type: LiteralUnion optimization (#39871)

pull/39546/merge
lijianan 2 years ago
committed by GitHub
parent
commit
d55d39b811
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/_util/type.ts
  2. 2
      components/badge/Ribbon.tsx
  3. 2
      components/badge/index.tsx
  4. 2
      components/tag/index.tsx
  5. 2
      components/tooltip/index.tsx

2
components/_util/type.ts

@ -1,2 +1,2 @@
/** https://github.com/Microsoft/TypeScript/issues/29729 */
export type LiteralUnion<T extends U, U> = T | (U & {});
export type LiteralUnion<T extends string> = T | (string & {});

2
components/badge/Ribbon.tsx

@ -13,7 +13,7 @@ export interface RibbonProps {
prefixCls?: string;
style?: React.CSSProperties; // style of ribbon element, not the wrapper
text?: React.ReactNode;
color?: LiteralUnion<PresetColorType, string>;
color?: LiteralUnion<PresetColorType>;
children?: React.ReactNode;
placement?: RibbonPlacement;
}

2
components/badge/index.tsx

@ -30,7 +30,7 @@ export interface BadgeProps {
scrollNumberPrefixCls?: string;
className?: string;
status?: PresetStatusColorType;
color?: LiteralUnion<PresetColorType, string>;
color?: LiteralUnion<PresetColorType>;
text?: React.ReactNode;
size?: 'default' | 'small';
offset?: [number | string, number | string];

2
components/tag/index.tsx

@ -15,7 +15,7 @@ export type { CheckableTagProps } from './CheckableTag';
export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
prefixCls?: string;
className?: string;
color?: LiteralUnion<PresetColorType | PresetStatusColorType, string>;
color?: LiteralUnion<PresetColorType | PresetStatusColorType>;
closable?: boolean;
closeIcon?: React.ReactNode;
/** @deprecated `visible` will be removed in next major version. */

2
components/tooltip/index.tsx

@ -71,7 +71,7 @@ interface LegacyTooltipProps
export interface AbstractTooltipProps extends LegacyTooltipProps {
style?: React.CSSProperties;
className?: string;
color?: LiteralUnion<PresetColorType, string>;
color?: LiteralUnion<PresetColorType>;
placement?: TooltipPlacement;
builtinPlacements?: typeof Placements;
openClassName?: string;

Loading…
Cancel
Save