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

improve types #1885

Merged
merged 1 commit into from Aug 16, 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
12 changes: 5 additions & 7 deletions src/mantine-styles/src/theme/types/MantineTheme.ts
Expand Up @@ -9,6 +9,7 @@ import type { CSSObject } from '../../tss';

export type LoaderType = 'bars' | 'oval' | 'dots';
export type MantineThemeOther = Record<string, any>;
export type MantineThemeComponents = Record<string, ThemeComponent>;

export interface HeadingStyle {
fontSize: CSSProperties['fontSize'];
Expand Down Expand Up @@ -86,7 +87,7 @@ export interface MantineTheme {
other: MantineThemeOther;
activeStyles: CSSObject;
datesLocale: string;
components: Record<string, ThemeComponent>;
components: MantineThemeComponents;
}

interface ThemeComponent {
Expand All @@ -98,9 +99,6 @@ interface ThemeComponent {
}

export type MantineThemeBase = Omit<MantineTheme, 'fn'>;
export type MantineThemeOverride = DeepPartial<
Omit<MantineThemeBase, 'fn' | 'other' | 'components'>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to omit fn as we're already doing that in MantineThemeBase

> & {
other?: MantineThemeOther;
components?: Record<string, ThemeComponent>;
};

export type MantineThemeOverride = DeepPartial<Omit<MantineThemeBase, 'other' | 'components'>> &
Partial<Pick<MantineThemeBase, 'other' | 'components'>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better and safer to Pick directly from MantineThemeBase, otherwise the types could fall out of sync