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

Replace empty object default type with any object #526

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions typescript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ interface FieldInputProps<T extends HTMLElement> {
multiple?: boolean;
}

interface AnyObject {
[key: string]: any;
}

export interface FieldRenderProps<T extends HTMLElement> {
input: FieldInputProps<T>;
meta: FieldMetaState;
Expand All @@ -42,7 +46,7 @@ export interface FormRenderProps<FormValues> extends FormState<FormValues> {
form: FormApi<FormValues>;
handleSubmit: (
event?: React.SyntheticEvent<HTMLFormElement>
) => Promise<object | undefined> | undefined;
) => Promise<AnyObject | undefined> | undefined;
}

export interface FormSpyRenderProps<FormValues> extends FormState<FormValues> {
Expand All @@ -55,13 +59,13 @@ export interface RenderableProps<T> {
render?: (props: T) => React.ReactNode;
}

export interface FormProps<FormValues = object>
export interface FormProps<FormValues = AnyObject>
extends Config<FormValues>,
RenderableProps<FormRenderProps<FormValues>> {
subscription?: FormSubscription;
decorators?: Decorator[];
form?: FormApi<FormValues>;
initialValuesEqual?: (a?: object, b?: object) => boolean;
initialValuesEqual?: (a?: AnyObject, b?: AnyObject) => boolean;
}

export interface UseFieldConfig {
Expand Down Expand Up @@ -89,7 +93,7 @@ export interface FieldProps<T extends HTMLElement>
[otherProp: string]: any;
}

export interface UseFormStateParams<FormValues = object> {
export interface UseFormStateParams<FormValues = AnyObject> {
onChange?: (formState: FormState<FormValues>) => void;
subscription?: FormSubscription;
}
Expand All @@ -99,16 +103,16 @@ export interface FormSpyProps<FormValues>
RenderableProps<FormSpyRenderProps<FormValues>> {}

export const Field: React.FC<FieldProps<any>>;
export const Form: React.FC<FormProps<object>>;
export const FormSpy: React.FC<FormSpyProps<object>>;
export const Form: React.FC<FormProps<AnyObject>>;
export const FormSpy: React.FC<FormSpyProps<AnyObject>>;
export function useField<T extends HTMLElement>(
name: string,
config?: UseFieldConfig
): FieldRenderProps<T>;
export function useForm<FormValues = object>(
export function useForm<FormValues = AnyObject>(
componentName?: string
): FormApi<FormValues>;
export function useFormState<FormValues = object>(
export function useFormState<FormValues = AnyObject>(
params?: UseFormStateParams
): FormState<FormValues>;
export function withTypes<FormValues>(): {
Expand Down