Skip to content

Commit

Permalink
fix(form): 修复dateFormatter使用string类型提示错误 (#8029)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhtry authored Dec 29, 2023
1 parent 0b26161 commit 6d764ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/form/src/BaseForm/BaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export type CommonFormProps<
* @example dateFormatter={(value)=>value.format("YYYY-MM-DD")}
*/
dateFormatter?:
| (string & {})
| 'string'
| 'number'
| ((value: dayjs.Dayjs, valueType: string) => string | number)
Expand Down
1 change: 1 addition & 0 deletions packages/table/src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export type ProTableProps<DataSource, U, ValueType = 'text'> = {
* @name 如何格式化日期
*/
dateFormatter?:
| (string & {})
| 'string'
| 'number'
| ((value: dayjs.Dayjs, valueType: string) => string | number)
Expand Down
6 changes: 2 additions & 4 deletions packages/utils/src/conversionMomentValue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ProFieldValueType } from '../typing';
dayjs.extend(quarterOfYear);

type DateFormatter =
| (string & {})
| 'number'
| 'string'
| ((value: dayjs.Dayjs, valueType: string) => string | number)
Expand Down Expand Up @@ -73,10 +74,7 @@ const isMoment = (value: any): boolean => !!value?._isAMomentObject;
*/
export const convertMoment = (
value: dayjs.Dayjs,
dateFormatter:
| string
| ((value: dayjs.Dayjs, valueType: string) => string | number)
| false,
dateFormatter: DateFormatter,
valueType: string,
) => {
if (!dateFormatter) {
Expand Down

0 comments on commit 6d764ad

Please sign in to comment.