Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: make createStyle go to original definition #3108

Merged
merged 2 commits into from Dec 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/mantine-styles/src/tss/create-styles.ts
Expand Up @@ -49,14 +49,14 @@ function getStyles<Key extends string>(
return extractStyles(styles);
}

export function createStyles<Key extends string = string, Params = void>(
export function createStyles<
Key extends string = string,
Params = void,
Input extends Record<Key, CSSObject> = Record<Key, CSSObject>
>(
input:
| ((
theme: MantineTheme,
params: Params,
createRef: (refName: string) => string
) => Record<Key, CSSObject>)
| Record<Key, CSSObject>
| ((theme: MantineTheme, params: Params, createRef: (refName: string) => string) => Input)
| Input
) {
const getCssObject = typeof input === 'function' ? input : () => input;

Expand All @@ -80,14 +80,18 @@ export function createStyles<Key extends string = string, Params = void>(
);
return [key, mergedStyles];
})
) as Record<Key, string>;
) 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,
}),
Expand Down