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

correct and improve typescript definitions #274

Merged
merged 5 commits into from
Aug 25, 2019

Conversation

stkevintan
Copy link
Contributor

  1. fix IFormAction and IAsyncFormAction types
  2. improve SchemaForm type definitions add types for Field
  3. and x-props type infer of Field when type is internal

@stkevintan stkevintan requested review from atzcl, monkindey and janryWang and removed request for atzcl August 20, 2019 10:57
type?: T
name?: string
editable?: boolean
['x-props']?: T extends keyof InternalFieldTypes ? InternalFieldTypes[T] : any
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的所有类型,能不能挪到./types.ts里去,全部放在一起,不方便维护

return
}
const published = this.publishState()
reducer(published, reducer)
callback(published, callback)
Copy link
Collaborator

@janryWang janryWang Aug 20, 2019

Choose a reason for hiding this comment

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

这里有bug,不应该再传callback进去,应该是我当时写的手误

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里我看到的时候也比较疑惑,原来如此

@@ -85,6 +85,8 @@ export class Form {
private traverse: (schema: ISchema) => ISchema

constructor(opts: IFormOptions) {
this.getFieldState = this.getFieldState.bind(this)
this.getFormState = this.getFormState.bind(this)
this.options = defaults<IFormOptions>(opts)
Copy link
Collaborator

Choose a reason for hiding this comment

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

用箭头函数不能重载么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

箭头函数是property不是method,不能重载

Copy link
Collaborator

Choose a reason for hiding this comment

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

能不能不用重载,用bind的形式,感觉不够优雅😂

import { TimePickerProps } from 'antd/lib/time-picker'
import { TransferProps } from 'antd/lib/transfer'
import { IUploaderProps } from './fields/upload'
import { SelectProps } from 'antd/lib/select'

Copy link
Collaborator

Choose a reason for hiding this comment

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

将依赖的类型统一放到./types.ts中吧,不然很难维护

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@janryWang done

wrapperCol?: ColProps | number
labelCol?: ColProps | number
labelTextAlign?: TextAlign
size?: Size
style?: React.CSSProperties
}

export interface IFormItemGridProps {
cols?: Array<number | { span: number; offset: number }>
Copy link
Collaborator

Choose a reason for hiding this comment

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

cols?: Array<number | { span: number; offset: number }>

改成

cols?: (number | ColSize)[]

会不会好点?

@janryWang janryWang merged commit 77e6c21 into alibaba:master Aug 25, 2019
@stkevintan stkevintan deleted the refactor_ts branch September 5, 2019 13:55
anyuxuan pushed a commit to anyuxuan/uform that referenced this pull request Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants