Skip to content

Commit bc441d3

Browse files
committed
Fix TS configuration so it can be used in our example screens
1 parent 99e49a0 commit bc441d3

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
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!')}>

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/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/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
}

tsconfig.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
// "emitDeclarationOnly": true,
1818
// "noImplicitAny": false
1919
"declaration": true,
20-
"baseUrl": "src",
21-
"paths": {}
20+
"baseUrl": ".",
21+
"paths": {
22+
"react-native-calendars": ["src/index.ts"],
23+
}
2224
},
2325
// "include": ["src/calendar/day/basic", "src/global.d.ts"],
24-
"include": ["src/**/*"],
26+
"include": ["src/**/*", "example/src/screens/calendars.tsx"],
2527
"exclude": ["node_modules", "testUtils"]
2628
}

0 commit comments

Comments
 (0)