Skip to content

Commit

Permalink
fix(core): fix the effects of IFormProps losing generic type (#1418)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL authored May 13, 2021
1 parent e79d0a3 commit ee8d118
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/shared/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
isVoidFieldState,
} from './checkers'

const createForm = <T extends Record<any, any> = any>(
const createForm = <T extends object = any>(
options?: IFormProps<T>
) => {
return new Form(options)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export type IFormState<T extends Record<any, any> = any> = Partial<

export type IFormGraph = Record<string, IGeneralFieldState | IFormState>

export interface IFormProps<T = any> {
export interface IFormProps<T extends object = any> {
values?: Partial<T>
initialValues?: Partial<T>
pattern?: FormPatternTypes
Expand All @@ -224,7 +224,7 @@ export interface IFormProps<T = any> {
disabled?: boolean
readOnly?: boolean
readPretty?: boolean
effects?: (form: Form) => void
effects?: (form: Form<T>) => void
validateFirst?: boolean
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Form } from '@formily/core/esm/models'
import { useContext } from 'react'
import { FormContext } from '../shared'

export const useForm = <T extends Record<any, any>>(): Form<T> => {
export const useForm = <T extends object = any>(): Form<T> => {
const form = useContext(FormContext)
if (!form) {
throw new Error('Can not found form instance from context.')
Expand Down

0 comments on commit ee8d118

Please sign in to comment.