From ef5c37a1fcee4a9f195e1286d6a2a73b40606aaa Mon Sep 17 00:00:00 2001 From: Siriwat K Date: Thu, 8 Aug 2024 10:31:22 +0700 Subject: [PATCH] [typescript] Fix `sx` types (#200) --- packages/pigment-css-react/src/sx.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/pigment-css-react/src/sx.d.ts b/packages/pigment-css-react/src/sx.d.ts index d9a19a42..4263a9e4 100644 --- a/packages/pigment-css-react/src/sx.d.ts +++ b/packages/pigment-css-react/src/sx.d.ts @@ -1,9 +1,11 @@ import type { CSSObjectNoCallback } from './base'; import type { ThemeArgs } from './theme'; +type GetTheme = Argument extends { theme: infer Theme } ? Theme : never; + export type SxProp = | CSSObjectNoCallback - | ((themeArgs: ThemeArgs['theme']) => CSSObjectNoCallback) - | ReadonlyArray CSSObjectNoCallback)>; + | ((theme: GetTheme) => CSSObjectNoCallback) + | ReadonlyArray) => CSSObjectNoCallback)>; -export default function sx(arg: SxProp | Array, componentClass?: string): string; +export default function sx(arg: SxProp, componentClass?: string): string;