type: optimize LiteralUnion type and add Primitive type (#55599)

This commit is contained in:
ayangweb
2025-11-04 23:00:08 +08:00
committed by GitHub
parent be0d352579
commit 51949965ce
2 changed files with 4 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
import type React from 'react';
export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
/** https://github.com/Microsoft/TypeScript/issues/29729 */
export type LiteralUnion<T extends string | undefined> = T | (string & {});
export type LiteralUnion<T, U extends Primitive = string> = T | (U & Record<never, never>);
export type AnyObject = Record<PropertyKey, any>;

View File

@@ -11,6 +11,6 @@ export interface FlexProps<P = AnyObject> extends React.HTMLAttributes<HTMLEleme
justify?: React.CSSProperties['justifyContent'];
align?: React.CSSProperties['alignItems'];
flex?: React.CSSProperties['flex'];
gap?: LiteralUnion<SizeType> | number;
gap?: LiteralUnion<SizeType, React.CSSProperties['gap']>;
component?: CustomComponent<P>;
}