Skip to content

Commit

Permalink
[core] Fix support for older versions of TypeScript
Browse files Browse the repository at this point in the history
Closes #20441
  • Loading branch information
NMinhNguyen committed Apr 6, 2020
1 parent cab2eee commit 0dc68d7
Show file tree
Hide file tree
Showing 39 changed files with 63 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,5 @@ export type AutocompleteClassKey =
* - [Autocomplete API](https://material-ui.com/api/autocomplete/)
*/
export default function Autocomplete<T>(
props: AutocompleteProps<T> & UseAutocompleteProps<T>,
props: AutocompleteProps<T> & UseAutocompleteProps<T>
): JSX.Element;
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/Pagination/Pagination.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface PaginationProps
getItemAriaLabel?: (
type: 'page' | 'first' | 'last' | 'next' | 'previous',
page: number,
selected: boolean,
selected: boolean
) => string;
/**
* Render the item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface FilterOptionsState<T> {
}

export function createFilterOptions<T>(
config?: CreateFilterOptionsConfig<T>,
config?: CreateFilterOptionsConfig<T>
): (options: T[], state: FilterOptionsState<T>) => T[];

export interface UseAutocompleteCommonProps<T> {
Expand Down Expand Up @@ -143,7 +143,7 @@ export interface UseAutocompleteCommonProps<T> {
onInputChange?: (
event: React.ChangeEvent<{}>,
value: string,
reason: AutocompleteInputChangeReason,
reason: AutocompleteInputChangeReason
) => void;
/**
* Callback fired when the popup requests to be opened.
Expand Down Expand Up @@ -210,7 +210,7 @@ export interface UseAutocompleteMultipleProps<T> extends UseAutocompleteCommonPr
event: React.ChangeEvent<{}>,
value: T[],
reason: AutocompleteChangeReason,
details?: AutocompleteChangeDetails<T>,
details?: AutocompleteChangeDetails<T>
) => void;
}

Expand Down Expand Up @@ -241,7 +241,7 @@ export interface UseAutocompleteSingleProps<T> extends UseAutocompleteCommonProp
event: React.ChangeEvent<{}>,
value: T | null,
reason: AutocompleteChangeReason,
details?: AutocompleteChangeDetails<T>,
details?: AutocompleteChangeDetails<T>
) => void;
}

Expand All @@ -250,7 +250,7 @@ export type UseAutocompleteProps<T> =
| UseAutocompleteMultipleProps<T>;

export default function useAutocomplete<T>(
props: UseAutocompleteProps<T>,
props: UseAutocompleteProps<T>
): {
getRootProps: () => {};
getInputProps: () => {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface ThemeProviderProps<Theme = DefaultTheme> {
theme: Partial<Theme> | ((outerTheme: Theme) => Theme);
}
export default function ThemeProvider<T = DefaultTheme>(
props: ThemeProviderProps<T>,
props: ThemeProviderProps<T>
): React.ReactElement<ThemeProviderProps<T>>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ import { StyleRules } from '@material-ui/styles/withStyles';
// See https://github.com/mui-org/material-ui/issues/15942
// and https://github.com/microsoft/TypeScript/issues/31735
export default function createStyles<ClassKey extends string, Props extends {}>(
styles: StyleRules<Props, ClassKey>,
styles: StyleRules<Props, ClassKey>
): StyleRules<Props, ClassKey>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export interface StylesCreator<Theme, Props extends object, ClassKey extends str
}

export default function getStylesCreator<S extends Styles<any, any>>(
style: S,
style: S
): StylesCreator<any, any>;
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/makeStyles/makeStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DefaultTheme } from '../defaultTheme';
*/
export default function makeStyles<Theme = DefaultTheme, ClassKey extends string = string>(
style: Styles<Theme, {}, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
): (props?: any) => ClassNameMap<ClassKey>;
/**
* `makeStyles` where the passed `styles` do depend on props
Expand All @@ -23,5 +23,5 @@ export default function makeStyles<
ClassKey extends string = string
>(
styles: Styles<Theme, Props, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
): (props: Props) => ClassNameMap<ClassKey>;
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/styled/styled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ComponentCreator<Component extends React.ElementType> = <
styles:
| CreateCSSProperties<Props>
| ((props: { theme: Theme } & Props) => CreateCSSProperties<Props>),
options?: WithStylesOptions<Theme>,
options?: WithStylesOptions<Theme>
) => React.ComponentType<
Omit<
JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
Expand All @@ -33,5 +33,5 @@ export interface StyledProps {
}

export default function styled<Component extends React.ElementType>(
Component: Component,
Component: Component
): ComponentCreator<Component>;
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/withStyles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type StyleRules<Props extends object = {}, ClassKey extends string = stri
* @internal
*/
export type StyleRulesCallback<Theme, Props extends object, ClassKey extends string = string> = (
theme: Theme,
theme: Theme
) => StyleRules<Props, ClassKey>;

export type Styles<Theme, Props extends object, ClassKey extends string = string> =
Expand Down Expand Up @@ -123,7 +123,7 @@ export default function withStyles<
Options extends WithStylesOptions<ThemeOfStyles<StylesType>> = {}
>(
style: StylesType,
options?: Options,
options?: Options
): PropInjector<
WithStyles<StylesType, Options['withTheme']>,
StyledComponentProps<ClassKeyOfStyles<StylesType>> & PropsOfStyles<StylesType>
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui-styles/src/withTheme/withTheme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export interface ThemedComponentProps extends Partial<WithTheme> {
}

export function withThemeCreator<Theme = DefaultTheme>(
option?: WithThemeCreatorOption<Theme>,
option?: WithThemeCreatorOption<Theme>
): PropInjector<WithTheme<Theme>, ThemedComponentProps>;

export default function withTheme<
Theme,
C extends React.ComponentType<ConsistentWith<React.ComponentProps<C>, WithTheme<Theme>>>
>(
component: C,
component: C
): React.ComponentType<
Omit<JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>, keyof WithTheme<Theme>> &
Partial<WithTheme<Theme>> &
Expand Down
6 changes: 3 additions & 3 deletions packages/material-ui-system/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
* @returns An enhanced stylefunction that considers breakpoints
*/
export function breakpoints<Props, Breakpoints extends string = DefaultBreakPoints>(
styleFunction: StyleFunction<Props>,
styleFunction: StyleFunction<Props>
): StyleFunction<Partial<Record<Breakpoints, Props>>>;

// compose.js
Expand All @@ -55,7 +55,7 @@ export function compose<T extends Array<StyleFunction<any>>>(...args: T): Compos

// css.js
export function css<Props>(
styleFunction: StyleFunction<Props>,
styleFunction: StyleFunction<Props>
): StyleFunction<Props & { css: Omit<Props, 'theme'> }>;

export const display: SimpleStyleFunction<
Expand Down Expand Up @@ -180,7 +180,7 @@ export interface StyleOptions<PropKey, Theme extends object> {
transform?: (cssValue: unknown) => number | string | React.CSSProperties;
}
export function style<PropKey extends string, Theme extends object>(
options: StyleOptions<PropKey, Theme>,
options: StyleOptions<PropKey, Theme>
): StyleFunction<{ [K in PropKey]?: unknown } & { theme: Theme }>;

// typography.js
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ConsistentWith<DecorationTargetProps, InjectedProps> = {
export type PropInjector<InjectedProps, AdditionalProps = {}> = <
C extends React.ComponentType<ConsistentWith<React.ComponentProps<C>, InjectedProps>>
>(
component: C,
component: C
) => React.ComponentType<
Omit<JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>, keyof InjectedProps> &
AdditionalProps
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Backdrop/Backdrop.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { StandardProps } from '..';
import { Omit, StandardProps } from '..';
import { FadeProps } from '../Fade';
import { TransitionProps } from '../transitions/transition';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Box/Box.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type BoxStyleFunction = ComposedStyleFunction<
typeof shadows,
typeof sizing,
typeof spacing,
typeof typography,
typeof typography
]
>;

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ButtonBase/ButtonBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ExtendButtonBaseTypeMap<M extends OverridableTypeMap> {
}

export type ExtendButtonBase<M extends OverridableTypeMap> = ((
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>,
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>
) => JSX.Element) &
OverridableComponent<ExtendButtonBaseTypeMap<M>>;

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/CardHeader/CardHeader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface OverridableCardHeader extends OverridableComponent<CardHeaderTy
Props,
TitleTypographyComponent,
SubheaderTypographyComponent
>,
>
): JSX.Element;
}

Expand Down
1 change: 1 addition & 0 deletions packages/material-ui/src/Fade/Fade.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Omit } from '..';
import { TransitionProps } from '../transitions/transition';

export interface FadeProps extends Omit<TransitionProps, 'children'> {
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Select/SelectInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface SelectInputProps {
disabled?: boolean;
IconComponent?: React.ElementType;
inputRef?: (
ref: HTMLSelectElement | { node: HTMLInputElement; value: SelectInputProps['value'] },
ref: HTMLSelectElement | { node: HTMLInputElement; value: SelectInputProps['value'] }
) => void;
MenuProps?: Partial<MenuProps>;
multiple: boolean;
Expand All @@ -16,7 +16,7 @@ export interface SelectInputProps {
onBlur?: React.FocusEventHandler<any>;
onChange?: (
event: React.ChangeEvent<{ name?: string; value: unknown }>,
child: React.ReactNode,
child: React.ReactNode
) => void;
onClose?: (event: React.ChangeEvent<{}>) => void;
onFocus?: React.FocusEventHandler<any>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Omit } from '..';

export interface TextareaAutosizeProps
extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'children' | 'rows'> {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createMixins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export interface MixinsOptions extends Partial<Mixins> {
export default function createMixins(
breakpoints: Breakpoints,
spacing: Spacing,
mixins: MixinsOptions,
mixins: MixinsOptions
): Mixins;
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createPalette.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface Palette {
color: ColorPartial,
mainShade?: number | string,
lightShade?: number | string,
darkShade?: number | string,
darkShade?: number | string
): PaletteColor;
(color: PaletteColorOptions): PaletteColor;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createSpacing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface Spacing {
top: SpacingArgument,
right: SpacingArgument,
bottom: SpacingArgument,
left: SpacingArgument,
left: SpacingArgument
): string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/createTypography.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ export interface TypographyOptions

export default function createTypography(
palette: Palette,
typography: TypographyOptions | ((palette: Palette) => TypographyOptions),
typography: TypographyOptions | ((palette: Palette) => TypographyOptions)
): Typography;
4 changes: 2 additions & 2 deletions packages/material-ui/src/styles/makeStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Omit } from '@material-ui/types';
*/
export default function makeStyles<Theme = DefaultTheme, ClassKey extends string = string>(
style: Styles<Theme, {}, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
): (props?: any) => ClassNameMap<ClassKey>;
/**
* `makeStyles` where the passed `styles` do depend on props
Expand All @@ -19,5 +19,5 @@ export default function makeStyles<
ClassKey extends string = string
>(
styles: Styles<Theme, Props, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
): (props: Props) => ClassNameMap<ClassKey>;
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/responsiveFontSizes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export interface ResponsiveFontSizesOptions {

export default function responsiveFontSizes(
theme: Theme,
options?: ResponsiveFontSizesOptions,
options?: ResponsiveFontSizesOptions
): Theme;
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/shadows.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Shadows = [
string,
string,
string,
string,
string
];
declare const shadows: Shadows;
export default shadows;
4 changes: 2 additions & 2 deletions packages/material-ui/src/styles/styled.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ComponentCreator<Component extends React.ElementType> = <
styles:
| CreateCSSProperties<Props>
| ((props: { theme: Theme } & Props) => CreateCSSProperties<Props>),
options?: WithStylesOptions<Theme>,
options?: WithStylesOptions<Theme>
) => React.ComponentType<
Omit<
JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
Expand All @@ -37,5 +37,5 @@ export interface StyledProps {
}

export default function styled<Component extends React.ElementType>(
Component: Component,
Component: Component
): ComponentCreator<Component>;
4 changes: 2 additions & 2 deletions packages/material-ui/src/styles/transitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Transitions {
duration: Duration;
create(
props: string | string[],
options?: Partial<{ duration: number | string; easing: string; delay: number | string }>,
options?: Partial<{ duration: number | string; easing: string; delay: number | string }>
): string;
getAutoHeightDuration(height: number): number;
}
Expand All @@ -34,7 +34,7 @@ export interface TransitionsOptions {
duration?: Partial<Duration>;
create?: (
props: string | string[],
options?: Partial<{ duration: number | string; easing: string; delay: number | string }>,
options?: Partial<{ duration: number | string; easing: string; delay: number | string }>
) => string;
getAutoHeightDuration?: (height: number) => number;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/styles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ export default function withStyles<
Props extends object = {}
>(
style: Styles<Theme, Props, ClassKey>,
options?: Options,
options?: Options
): PropInjector<WithStyles<ClassKey, Options['withTheme']>, StyledComponentProps<ClassKey> & Props>;
2 changes: 1 addition & 1 deletion packages/material-ui/src/test-utils/createMount.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface MountOptions {
}

export default function createMount(
options?: Partial<MountOptions>,
options?: Partial<MountOptions>
): typeof mount & {
attachTo: HTMLElement;
cleanUp(): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/test-utils/getClasses.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function getClasses<T = { [name: string]: string }>(
element: React.ReactElement,
options?: Partial<{ withTheme: boolean }>,
options?: Partial<{ withTheme: boolean }>
): T;
2 changes: 1 addition & 1 deletion packages/material-ui/src/test-utils/until.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { CommonWrapper } from 'enzyme';

export default function until<P = any, S = any>(
selector: string,
options: { context: any },
options: { context: any }
): CommonWrapper<P, S>;
2 changes: 1 addition & 1 deletion packages/material-ui/src/useMediaQuery/useMediaQuery.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export interface Options {

export default function useMediaQuery<Theme = unknown>(
query: string | ((theme: Theme) => string),
options?: Options,
options?: Options
): boolean;
2 changes: 1 addition & 1 deletion packages/material-ui/src/utils/debounce.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export interface Cancelable {

export default function debounce<T extends (...args: any[]) => any>(
func: T,
wait?: number,
wait?: number
): T & Cancelable;
2 changes: 1 addition & 1 deletion packages/material-ui/src/utils/setRef.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
*/
export default function setRef<T>(
ref: React.RefObject<T> | ((instance: T | null) => void) | null | undefined,
value: T | null,
value: T | null
): void;
Loading

0 comments on commit 0dc68d7

Please sign in to comment.