From ecb4b15d9be284be42b903db36c1a0fed3a6bb05 Mon Sep 17 00:00:00 2001 From: Parbez Date: Sat, 10 Dec 2022 13:19:52 +0530 Subject: [PATCH] [@mantine/styles] Allow createStyle to go to the original definition (#3108) * types: make createStyle go to original definition * fix: fix the typings again --- src/mantine-styles/src/tss/create-styles.ts | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/mantine-styles/src/tss/create-styles.ts b/src/mantine-styles/src/tss/create-styles.ts index a4a931f6c12..b9027122e8e 100644 --- a/src/mantine-styles/src/tss/create-styles.ts +++ b/src/mantine-styles/src/tss/create-styles.ts @@ -49,14 +49,14 @@ function getStyles( return extractStyles(styles); } -export function createStyles( +export function createStyles< + Key extends string = string, + Params = void, + Input extends Record = Record +>( input: - | (( - theme: MantineTheme, - params: Params, - createRef: (refName: string) => string - ) => Record) - | Record + | ((theme: MantineTheme, params: Params, createRef: (refName: string) => string) => Input) + | Input ) { const getCssObject = typeof input === 'function' ? input : () => input; @@ -80,14 +80,18 @@ export function createStyles( ); return [key, mergedStyles]; }) - ) as Record; + ) as { + [key in keyof Input]: string; + }; return { - classes: mergeClassNames({ + classes: mergeClassNames<{ [key in keyof Input]: string }>({ cx, classes, context, - classNames: options?.classNames, + classNames: options?.classNames as { + [key in keyof Input]: string; + }, name: options?.name, cache, }),