Browse Source

chore(Tag): improve color types (#22999)

pull/23004/head
Jay Fong 5 years ago
committed by GitHub
parent
commit
b41301b168
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      components/_util/type.ts
  2. 10
      components/tag/index.tsx

5
components/_util/type.ts

@ -9,3 +9,8 @@ export const tupleNum = <T extends number[]>(...args: T) => args;
* Extract the type of an element of an array/tuple without performing indexing
*/
export type ElementOf<T> = T extends (infer E)[] ? E : T extends readonly (infer E)[] ? E : never;
/**
* https://github.com/Microsoft/TypeScript/issues/29729
*/
export type LiteralUnion<T extends U, U> = T | (U & {});

10
components/tag/index.tsx

@ -5,15 +5,21 @@ import CloseOutlined from '@ant-design/icons/CloseOutlined';
import CheckableTag from './CheckableTag';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import { PresetColorTypes, PresetStatusColorTypes } from '../_util/colors';
import {
PresetColorTypes,
PresetStatusColorTypes,
PresetColorType,
PresetStatusColorType,
} from '../_util/colors';
import Wave from '../_util/wave';
import { LiteralUnion } from '../_util/type';
export { CheckableTagProps } from './CheckableTag';
export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
prefixCls?: string;
className?: string;
color?: string;
color?: LiteralUnion<PresetColorType | PresetStatusColorType, string>;
closable?: boolean;
visible?: boolean;
onClose?: Function;

Loading…
Cancel
Save