diff --git a/components/_util/type.ts b/components/_util/type.ts index 7620c9db1c..303929d1ec 100644 --- a/components/_util/type.ts +++ b/components/_util/type.ts @@ -9,3 +9,8 @@ export const tupleNum = (...args: T) => args; * Extract the type of an element of an array/tuple without performing indexing */ export type ElementOf = T extends (infer E)[] ? E : T extends readonly (infer E)[] ? E : never; + +/** + * https://github.com/Microsoft/TypeScript/issues/29729 + */ +export type LiteralUnion = T | (U & {}); diff --git a/components/tag/index.tsx b/components/tag/index.tsx index 1dfdbae78e..6644bc4db1 100644 --- a/components/tag/index.tsx +++ b/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 { prefixCls?: string; className?: string; - color?: string; + color?: LiteralUnion; closable?: boolean; visible?: boolean; onClose?: Function;