Skip to content

Commit e8e97e6

Browse files
authored
Merge pull request #1704 from wix/fix/TSConfiguration
Fix/ts configuration
2 parents 25a27ab + fb40a3f commit e8e97e6

File tree

11 files changed

+31
-22
lines changed

11 files changed

+31
-22
lines changed

example/src/screens/calendars.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, {useState, Fragment} from 'react';
22
import {StyleSheet, View, ScrollView, Text, TouchableOpacity, Switch} from 'react-native';
3-
// @ts-expect-error
4-
import {Calendar} from 'react-native-calendars';
3+
import {Calendar, CalendarProps} from 'react-native-calendars';
54
import testIDs from '../testIDs';
65

76
const INITIAL_DATE = '2020-02-02';
@@ -14,7 +13,7 @@ const CalendarsScreen = () => {
1413
setShowMarkedDatesExamples(!showMarkedDatesExamples);
1514
};
1615

17-
const onDayPress = day => {
16+
const onDayPress: CalendarProps['onDayPress'] = day => {
1817
setSelected(day.dateString);
1918
};
2019

@@ -349,7 +348,7 @@ const CalendarsScreen = () => {
349348
return (
350349
<View>
351350
<Text style={[styles.customDay, state === 'disabled' ? styles.disabledText : styles.defaultText]}>
352-
{date.day}
351+
{date?.day}
353352
</Text>
354353
</View>
355354
);
@@ -362,6 +361,7 @@ const CalendarsScreen = () => {
362361
const renderCalendarWithCustomHeader = () => {
363362
const CustomHeader = React.forwardRef((props, ref) => {
364363
return (
364+
// @ts-expect-error
365365
<View ref={ref} {...props} style={styles.customHeader}>
366366
<Text>This is a custom header!</Text>
367367
<TouchableOpacity onPress={() => console.warn('Tapped!')}>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@babel/eslint-parser": "^7.13.4",
4444
"@babel/runtime": "^7.12.5",
4545
"@types/lodash": "^4.14.170",
46-
"@types/react-native": "^0.63.52",
46+
"@types/react-native": "^0.64.19",
4747
"@types/xdate": "^0.8.32",
4848
"@typescript-eslint/eslint-plugin": "^2.13.0",
4949
"@typescript-eslint/parser": "^2.13.0",

src/agenda/reservation-list/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {sameDate} from '../../dateutils';
1010
import {toMarkingFormat} from '../../interface';
1111
import styleConstructor from './style';
1212
import Reservation, {ReservationProps} from './reservation';
13-
import {ReservationItemType, ReservationsType} from 'agenda';
13+
import {ReservationItemType, ReservationsType} from '../../agenda';
1414

1515

1616
export interface DayReservations {

src/calendar/day/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ import {SELECT_DATE_SLOT} from '../../testIDs';
1313
import BasicDay, {BasicDayProps} from './basic';
1414
import PeriodDay from './period';
1515
import {MarkingProps} from './marking';
16+
import {DateData} from '../../types';
1617

1718
const basicDayPropsTypes = omit(BasicDay.propTypes, 'date');
1819

1920
export interface DayProps extends Omit<BasicDayProps, 'date'> {
2021
/** The day to render */
2122
day?: XDate;
2223
/** Provide custom day rendering component */
23-
dayComponent?: any;
24+
dayComponent?: React.ComponentType<DayProps & {date?: DateData}>;
2425
}
2526

2627
export default class Day extends Component<DayProps> {

src/calendar/day/marking/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import filter from 'lodash/filter';
22

33
import React, {Component} from 'react';
4-
import {View, ViewStyle, TextStyle} from 'react-native';
4+
import {View, ViewStyle, TextStyle, StyleProp} from 'react-native';
55

66
import {Theme, MarkingTypes} from '../../../types';
77
import {shouldUpdate, extractComponentProps} from '../../../componentUpdater';
@@ -44,8 +44,11 @@ export interface MarkingProps extends DotProps {
4444
inactive?: boolean;
4545
disableTouchEvent?: boolean;
4646
activeOpacity?: number;
47+
textColor?: string;
4748
selectedColor?: string;
4849
selectedTextColor?: string;
50+
customTextStyle?: StyleProp<TextStyle>;
51+
customContainerStyle?: StyleProp<ViewStyle>;
4952
dotColor?: string;
5053
//multi-dot
5154
dots?: DOT[];

src/calendar/header/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default function (theme: Theme = {}) {
3939
disabledArrowImage: {
4040
tintColor: appStyle.disabledArrowColor
4141
},
42+
// @ts-expect-error
4243
week: {
4344
marginTop: 7,
4445
flexDirection: 'row',
@@ -57,7 +58,6 @@ export default function (theme: Theme = {}) {
5758
disabledDayHeader: {
5859
color: appStyle.textSectionTitleDisabledColor
5960
},
60-
// @ts-expect-error
6161
...(theme['stylesheet.calendar.header'] || {})
6262
});
6363
}

src/calendar/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export interface CalendarProps extends CalendarHeaderProps, DayProps {
3131
/** Specify style for calendar container element */
3232
style?: StyleProp<ViewStyle>;
3333
/** Initially visible month */
34-
current?: XDate;
34+
current?: string;
3535
/** Minimum date that can be selected, dates before minDate will be grayed out */
36-
minDate?: XDate;
36+
minDate?: string;
3737
/** Maximum date that can be selected, dates after maxDate will be grayed out */
38-
maxDate?: XDate;
38+
maxDate?: string;
3939
/** If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday */
4040
firstDay?: number;
4141
/** Collection of dates that have to be marked */

src/expandableCalendar/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {AccessibilityInfo, PanResponder, Animated, View, ViewStyle, Text, Image,
1313
import {CALENDAR_KNOB} from '../testIDs';
1414
import {page, weekDayNames} from '../dateutils';
1515
import {parseDate, toMarkingFormat} from '../interface';
16-
import {Theme, DateData, Direction} from 'types';
16+
import {Theme, DateData, Direction} from '../types';
1717
import styleConstructor, {HEADER_HEIGHT} from './style';
1818
import CalendarList, {CalendarListProps} from '../calendar-list';
1919
import Calendar from '../calendar';
@@ -139,7 +139,7 @@ class ExpandableCalendar extends Component<Props, State> {
139139
style: ViewStyle;
140140
};
141141
visibleMonth: number;
142-
visibleYear: number;
142+
visibleYear: number | undefined;
143143
initialDate: XDate;
144144
headerStyleOverride: Theme;
145145
header: React.RefObject<any> = React.createRef();
@@ -436,7 +436,6 @@ class ExpandableCalendar extends Component<Props, State> {
436436
if (month && this.visibleMonth !== month) {
437437
this.visibleMonth = month;
438438
if (first(value)?.year) {
439-
// @ts-expect-error
440439
this.visibleYear = first(value)?.year;
441440
}
442441

@@ -580,6 +579,7 @@ class ExpandableCalendar extends Component<Props, State> {
580579
{...others}
581580
theme={themeObject}
582581
ref={this.calendar}
582+
// @ts-expect-error should be converted to string
583583
current={this.initialDate}
584584
onDayPress={this.onDayPress}
585585
onVisibleMonthsChange={this.onVisibleMonthsChange}

src/expandableCalendar/week.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import Day from '../calendar/day/index';
1212
// import BasicDay from '../calendar/day/basic';
1313

1414

15-
interface Props extends CalendarProps {
15+
// TODO: current type should be a string
16+
interface Props extends Omit<CalendarProps, 'current'> {
1617
current: XDate;
1718
}
1819
export type WeekProps = Props;

src/types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {ViewStyle, TextStyle} from 'react-native';
1+
import {ViewStyle, TextStyle, StyleProp} from 'react-native';
22
import {UpdateSources} from './expandableCalendar/commons';
33

4-
54
export type MarkingTypes = 'dot' | 'multi-dot' | 'period' | 'multi-period' | 'custom';
65
export type DayState = 'selected' | 'disabled' | 'inactive' | 'today' | '';
76
export type Direction = 'left' | 'right';
@@ -12,7 +11,7 @@ export type DateData = {
1211
day: number;
1312
timestamp: number;
1413
dateString: string;
15-
}
14+
};
1615
export interface Theme {
1716
container?: object;
1817
contentStyle?: ViewStyle;
@@ -88,4 +87,7 @@ export interface Theme {
8887
arrowHeight?: number;
8988
arrowWidth?: number;
9089
weekVerticalMargin?: number;
90+
'stylesheet.calendar.header'?: {
91+
week: StyleProp<ViewStyle>;
92+
};
9193
}

0 commit comments

Comments
 (0)