Skip to content

Commit

Permalink
refactor: do not use method syntax for weirdness with this
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Oct 9, 2024
1 parent 72044e0 commit 08a8952
Show file tree
Hide file tree
Showing 79 changed files with 210 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function ChipWithCircularProgressExample(): ReactElement {
interface DemoStateHookResult {
enabled: boolean;
loading: boolean;
onClick(): void;
onClick: () => void;
}

function useDemoState(): DemoStateHookResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function NestedDialogsExample(): ReactElement {

interface InfiniteDialogProps {
depth: number;
closeAll(): void;
closeAll: () => void;
}

function InfiniteDialog(props: InfiniteDialogProps): ReactElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function NestedDialogsVisibleExample(): ReactElement {

interface InfiniteDialogProps {
depth: number;
closeAll(): void;
closeAll: () => void;
}

function InfiniteDialog(props: InfiniteDialogProps): ReactElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function DisableDeterminateTransition(): ReactElement {
const UPDATE_INTERVAL = 10;

interface ProgressControls {
toggle(): void;
restart(): void;
toggle: () => void;
restart: () => void;
running: boolean;
progress: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ interface SortState {
}

interface SortedColumnsHookResult extends SortState {
update(sortKey: DessertKey): void;
update: (sortKey: DessertKey) => void;
}

function useSortedColumns(): SortedColumnsHookResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const max = ADDONS.length - 1;

interface RotatingAddonsProps
extends Pick<TextFieldProps, "leftAddon" | "rightAddon"> {
toggle(): void;
toggle: () => void;
running: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function ProgressbarTooltipExample(): ReactElement {

function useIncrementingValue(): {
value: number;
toggle(): void;
toggle: () => void;
toggled: boolean;
} {
const { toggled, toggle } = useToggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,7 @@ used instead.
+import { SimplePosition, useTooltip } from "react-md";

interface Test1Props {
onClick?(event: MouseEvent): void;
onClick?: (event: MouseEvent) => void;
```

### 🔧 update-tooltip-props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export interface MaterialIconsAndSymbolsContext
weight: MaterialSymbolWeight;
grade: MaterialSymbolGrade;
opticalSize: MaterialSymbolOpticalSize;
selectIcon(name: MaterialIconAndSymbolName): void;
deselectIcon(): void;
toggleFilters(): void;
resetSymbols(): void;
resetFilters(): void;
selectIcon: (name: MaterialIconAndSymbolName) => void;
deselectIcon: () => void;
toggleFilters: () => void;
resetSymbols: () => void;
resetFilters: () => void;
isFillChanged: boolean;
isGradeChanged: boolean;
isWeightChanged: boolean;
Expand All @@ -81,9 +81,9 @@ export interface MaterialIconsAndSymbolsContext
isFontFamilyChanged: boolean;
isSymbolCustomizationChanged: boolean;
isResettable: boolean;
setSearch(search: string): void;
setIconType(iconType: IconType): void;
setIconFamily(iconFamily: MaterialIconFamily): void;
setIconCategory(iconCategory: IconCategoryFilter): void;
changeSvgToFont(): void;
setSearch: (search: string) => void;
setIconType: (iconType: IconType) => void;
setIconFamily: (iconFamily: MaterialIconFamily) => void;
setIconCategory: (iconCategory: IconCategoryFilter) => void;
changeSvgToFont: () => void;
}
2 changes: 1 addition & 1 deletion apps/docs/src/app/(main)/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type ReactElement } from "react";

export interface ErrorPageProps {
error: Error & { digest?: string };
reset(): void;
reset: () => void;
}

export default function ErrorPage(props: ErrorPageProps): ReactElement {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/components/PrismThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

export interface PrismThemeContext {
prismTheme: PrismTheme;
setPrismTheme(theme: PrismTheme): void;
setPrismTheme: (theme: PrismTheme) => void;
}

const context = createContext<PrismThemeContext | null>(null);
Expand Down
3 changes: 1 addition & 2 deletions apps/docs/src/components/SegmentedButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ const noop = (): ReactNode => undefined;
export interface SegmentedButtonsProps<V extends string>
extends Omit<SegmentedButtonContainerProps, "children"> {
textTransform?: TextTransform;

icon?: Record<V, ReactNode> | ((item: V) => ReactNode);
items: readonly V[];
value: V;
setValue(nextValue: V): void;
setValue: (nextValue: V) => void;
}

export function SegmentedButtons<V extends string>(
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/utils/serverCookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "server-only";

interface GetCookieOptions<V extends string> {
name: string;
isValid(value: string): value is V;
isValid: (value: string) => value is V;
defaultValue: V;
instance: ReturnType<typeof cookies>;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/code/src/CopyToClipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const noop = (): void => {
};

export interface CopyToClipboardProps extends TooltippedButtonProps {
onCopied?(text: string): void;
onCopied?: (text: string) => void;
copyText?: string;
getCopyText?(button: HTMLButtonElement): string;
getCopyText?: (button: HTMLButtonElement) => string;
}

export function CopyToClipboard(
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/DangerousCodeRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { type RunnableCodeScope } from "./types.js";
import { type DangerouslyRunCodeOptions } from "./useDangerousCodeRunner.js";

export interface DangerousCodeRunnerProps extends DangerouslyRunCodeOptions {
onRendered(error: Error | null): void;
onRendered: (error: Error | null) => void;
}

export interface DangerousCodeRunnerState {
Expand Down
4 changes: 2 additions & 2 deletions packages/code/src/PackageManagerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const DEFAULT_PACKAGE_MANAGERS: readonly PackageManager[] = [
export interface PackageManagerContext {
packageManager: PackageManager;
packageManagers: readonly PackageManager[];
setPackageManager(packageManager: PackageManager): void;
setPackageManager: (packageManager: PackageManager) => void;
}

const context = createContext<PackageManagerContext | null>(null);
Expand All @@ -44,7 +44,7 @@ export interface PackageManagerProviderProps {
children: ReactNode;
defaultValue?: UseStateInitializer<PackageManager>;
packageManagers?: readonly PackageManager[];
onPackageManagerChange?(nextPackageManager: PackageManager): void;
onPackageManagerChange?: (nextPackageManager: PackageManager) => void;
}

export function PackageManagerProvider(
Expand Down
4 changes: 2 additions & 2 deletions packages/code/src/TypescriptEnabledProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const noop = (): void => {

export interface TypescriptEnabledContext {
isTypescriptEnabled: boolean;
setTypescriptEnabled(enabled: boolean): void;
setTypescriptEnabled: (enabled: boolean) => void;
}

const context = createContext<TypescriptEnabledContext | null>(null);
Expand All @@ -34,7 +34,7 @@ export function useTypescriptEnabledContext(): TypescriptEnabledContext {
export interface TypescriptEnabledProviderProps {
children: ReactNode;
defaultValue?: UseStateInitializer<boolean>;
onTypescriptEnabledChange?(enabled: boolean): void;
onTypescriptEnabledChange?: (enabled: boolean) => void;
}

export function TypescriptEnabledProvider(
Expand Down
8 changes: 4 additions & 4 deletions packages/code/src/useCodeEditHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface CodeEditHistory {

interface HandleKeydownOptions extends Required<CodeEditTextAction> {
event: KeyboardEvent<HTMLTextAreaElement>;
update(editAction: CodeEditTextAction): void;
update: (editAction: CodeEditTextAction) => void;
}

const TAB_TEXT = " ".repeat(2);
Expand Down Expand Up @@ -199,9 +199,9 @@ export interface CodeEditHistoryImplementation {
onChange: ChangeEventHandler<HTMLTextAreaElement>;
onKeyDown: KeyboardEventHandler<HTMLTextAreaElement>;
};
setCode(nextCode: string): void;
editCode(action: CodeEditAction): void;
updateTextArea(action: CodeEditTextAction): void;
setCode: (nextCode: string) => void;
editCode: (action: CodeEditAction) => void;
updateTextArea: (action: CodeEditTextAction) => void;
}

export function useCodeEditHistory(
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/useDangerousCodeRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const noop = (): void => {
};

export interface DangerouslyRunCodeOptions extends DangerouslyEvalCodeOptions {
onRendered?(error: Error | null): void;
onRendered?: (error: Error | null) => void;
}

export interface DangerouslyRunCodeResult {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/useAsyncFunction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CircularProgress } from "../progress/CircularProgress.js";
import { useAsyncFunction } from "../useAsyncFunction.js";

interface TestProps extends ButtonProps {
onClick(event: MouseEvent<HTMLButtonElement>): Promise<void>;
onClick: (event: MouseEvent<HTMLButtonElement>) => Promise<void>;
hookDisabled?: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/useThrottledFunction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const fakeFetch = jest.fn((search: string) =>

interface AsyncTestProps {
unmounted: MutableRefObject<boolean>;
onUnmounted(): void;
onUnmounted: () => void;
}

function AsyncTest(props: AsyncTestProps): ReactElement {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export interface AutocompleteBaseProps<Option extends AutocompleteOption>
* }}
* ```
*/
getOptionProps?(
getOptionProps?: (
options: AutocompleteGetOptionPropsOptions<Option>
): ConfigurableAutocompleteOptionProps | undefined;
) => ConfigurableAutocompleteOptionProps | undefined;

/**
* This can be used to add any custom styling, change the icon, change the
Expand Down Expand Up @@ -134,7 +134,7 @@ export interface AutocompleteBaseProps<Option extends AutocompleteOption>
*/
disableClearButton?: boolean;

onOpen?(): void;
onOpen?: () => void;

/**
* The children to display when there are no {@link options} due to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export interface AutocompleteListboxChildrenProps<
Option extends AutocompleteOption,
> {
options: readonly Option[];
getOptionLabel(option: Option): string;
getOptionProps(
getOptionLabel: (option: Option) => string;
getOptionProps: (
options: AutocompleteGetOptionPropsOptions<Option>
): ConfigurableAutocompleteOptionProps | undefined;
) => ConfigurableAutocompleteOptionProps | undefined;
children: ReactNode;
noOptionsChildren: ReactNode;
}
Expand Down
23 changes: 11 additions & 12 deletions packages/core/src/autocomplete/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export interface AutocompleteUnknownQueryAndValueOptions<
export type AutocompleteOptionLabelExtractor<
Option extends AutocompleteOption,
> = Option extends AutocompleteLabeledOption
? { getOptionLabel?(option: Option): string }
: { getOptionLabel(option: Option): string };
? { getOptionLabel?: (option: Option) => string }
: { getOptionLabel: (option: Option) => string };

/**
* @since 6.0.0
Expand Down Expand Up @@ -196,7 +196,7 @@ export interface AutocompleteFilteringOptions<
*
* @defaultValue `defaultAutocompleteExtractor`
*/
getOptionLabel?(option: Option): string;
getOptionLabel?: (option: Option) => string;

/**
* The function that filters the {@link options} based on the current query
Expand Down Expand Up @@ -269,8 +269,7 @@ export interface AutocompleteEditableComboboxOptions<
ListboxSelectIconProps {
onBlur?: FocusEventHandler<ComboboxEl>;
onChange?: ChangeEventHandler<ComboboxEl>;

onOpen?(): void;
onOpen?: () => void;
}

/**
Expand Down Expand Up @@ -336,7 +335,7 @@ export interface AutocompleteListboxProps<
ListboxSelectIconProps {
value: T | null | readonly T[];
setValue: Dispatch<T>;
onEnter(appearing: boolean): void;
onEnter: (appearing: boolean) => void;
}

/**
Expand All @@ -360,15 +359,15 @@ export interface AutocompleteWithQueryImplementation<
setQuery: Dispatch<string>;
comboboxProps: AutocompleteComboboxProps<ComboboxEl>;
availableOptions: readonly Option[];
getListboxProps(
getListboxProps: (
overrides?: ConfigurableAutocompleteListboxProps
): AutocompleteListboxProps<Option, PopupEl>;
getClearButtonProps(
) => AutocompleteListboxProps<Option, PopupEl>;
getClearButtonProps: (
overrides?: ConfigurableAutocompleteClearButtonProps
): AutocompleteClearButtonProps;
getDropdownButtonProps(
) => AutocompleteClearButtonProps;
getDropdownButtonProps: (
overrides?: ConfigurableAutocompleteDropdownButtonProps
): AutocompleteDropdownButtonProps;
) => AutocompleteDropdownButtonProps;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/autocomplete/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export interface GetDefaultValueOptions<Option extends AutocompleteOption> {
| UseStateInitializer<Option | null | readonly Option[]>
| undefined;
options: readonly Option[];
getOptionLabel(value: Option): string;
filter(options: AutocompleteFilterOptions<Option>): readonly Option[];
getOptionLabel: (value: Option) => string;
filter: (options: AutocompleteFilterOptions<Option>) => readonly Option[];
}

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ export function getDefaultValue<Option extends AutocompleteOption>(
*/
interface GetDefaultQueryOptions<Option extends AutocompleteOption> {
value: Option | null | readonly Option[];
getOptionLabel(option: Option): string;
getOptionLabel: (option: Option) => string;
defaultQuery?: UseStateInitializer<string>;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/button/AsyncButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface AsyncButtonProps extends ButtonProps {
*
* @defaultValue `() => {}`
*/
onClick?(event: MouseEvent<HTMLButtonElement>): Promise<void> | void;
onClick?: (event: MouseEvent<HTMLButtonElement>) => Promise<void> | void;

/**
* Set this to `true` to manually display a loading spinner.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/delegateEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export interface DelegatedEventHandler {
/**
* Adds the provided callback to the throttled event listener.
*/
add(callback: EventListener): void;
add: (callback: EventListener) => void;

/**
* Attempts to remove the provided callback from the throttled event listener.
*/
remove(callback: EventListener): void;
remove: (callback: EventListener) => void;
}

/** @internal */
Expand Down
Loading

0 comments on commit 08a8952

Please sign in to comment.