Skip to content

Commit dabd40a

Browse files
committed
refactor(types): 修复类型问题
1 parent bc66276 commit dabd40a

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

packages/taro-ui/rn/components/calendar/common/plugins.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export function handleActive(
2121
const dayjsStart = start ? dayjs(start) : dayjsEnd
2222

2323
item.isSelected =
24-
_value.isSame(dayjsEnd) ||
25-
_value.isSame(dayjsStart) ||
26-
(_value.isAfter(dayjsStart) && _value.isBefore(dayjsEnd))
24+
_value?.isSame(dayjsEnd) ||
25+
_value?.isSame(dayjsStart) ||
26+
(_value?.isAfter(dayjsStart) && _value?.isBefore(dayjsEnd))
2727

28-
item.isSelectedHead = _value.isSame(dayjsStart)
29-
item.isSelectedTail = _value.isSame(dayjsEnd)
28+
item.isSelectedHead = _value?.isSame(dayjsStart)
29+
item.isSelectedTail = _value?.isSame(dayjsEnd)
3030

31-
item.isToday = _value.diff(dayjs(Date.now()).startOf('day'), 'day') === 0
31+
item.isToday = _value?.diff(dayjs(Date.now()).startOf('day'), 'day') === 0
3232

3333
return item
3434
}
@@ -94,8 +94,8 @@ export function handleDisabled(
9494
const dayjsMaxDate = dayjs(maxDate)
9595

9696
item.isDisabled =
97-
!!(minDate && _value.isBefore(dayjsMinDate)) ||
98-
!!(maxDate && _value.isAfter(dayjsMaxDate))
97+
!!(minDate && _value?.isBefore(dayjsMinDate)) ||
98+
!!(maxDate && _value?.isAfter(dayjsMaxDate))
9999

100100
return item
101101
}

packages/taro-ui/src/components/calendar/common/plugins.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export function handleActive(
2121
const dayjsStart = start ? dayjs(start) : dayjsEnd
2222

2323
item.isSelected =
24-
_value.isSame(dayjsEnd) ||
25-
_value.isSame(dayjsStart) ||
26-
(_value.isAfter(dayjsStart) && _value.isBefore(dayjsEnd))
24+
_value?.isSame(dayjsEnd) ||
25+
_value?.isSame(dayjsStart) ||
26+
(_value?.isAfter(dayjsStart) && _value?.isBefore(dayjsEnd))
2727

28-
item.isSelectedHead = _value.isSame(dayjsStart)
29-
item.isSelectedTail = _value.isSame(dayjsEnd)
28+
item.isSelectedHead = _value?.isSame(dayjsStart)
29+
item.isSelectedTail = _value?.isSame(dayjsEnd)
3030

31-
item.isToday = _value.diff(dayjs(Date.now()).startOf('day'), 'day') === 0
31+
item.isToday = _value?.diff(dayjs(Date.now()).startOf('day'), 'day') === 0
3232

3333
return item
3434
}
@@ -94,8 +94,8 @@ export function handleDisabled(
9494
const dayjsMaxDate = dayjs(maxDate)
9595

9696
item.isDisabled =
97-
!!(minDate && _value.isBefore(dayjsMinDate)) ||
98-
!!(maxDate && _value.isAfter(dayjsMaxDate))
97+
!!(minDate && _value?.isBefore(dayjsMinDate)) ||
98+
!!(maxDate && _value?.isAfter(dayjsMaxDate))
9999

100100
return item
101101
}

packages/taro-ui/types/calendar.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ declare namespace Calendar {
2121
export interface Item {
2222
value: string
2323

24-
_value: dayjs.Dayjs
24+
_value?: dayjs.Dayjs
2525

2626
text: number
2727

@@ -46,6 +46,12 @@ declare namespace Calendar {
4646
isSelectedTail?: boolean
4747
}
4848

49+
export interface SelectedDate {
50+
end?: Calendar.DateArg
51+
52+
start: Calendar.DateArg
53+
}
54+
4955
export interface GroupOptions {
5056
validDates: Array<ValidDate>
5157

@@ -67,12 +73,6 @@ declare namespace Calendar {
6773

6874
list: List<T>
6975
}
70-
71-
export interface SelectedDate {
72-
end?: Calendar.DateArg
73-
74-
start: Calendar.DateArg
75-
}
7676
}
7777

7878
export default Calendar
@@ -181,7 +181,7 @@ export interface AtCalendarControllerProps {
181181
onSelectDate: (e: BaseEvent) => void
182182
}
183183

184-
export interface AtCalendarControllerState { }
184+
export interface AtCalendarControllerState {}
185185
// #endregion
186186

187187
// #region AtCalendarBody

0 commit comments

Comments
 (0)