Skip to content

Commit

Permalink
Add explicit function return types
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jun 26, 2024
1 parent f2225fe commit 96ec191
Show file tree
Hide file tree
Showing 21 changed files with 487 additions and 473 deletions.
898 changes: 452 additions & 446 deletions packages/react-calendar/src/Calendar.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/react-calendar/src/Calendar/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default function Navigation({
showDoubleView,
view,
views,
}: NavigationProps) {
}: NavigationProps): React.ReactElement {
const drillUpAvailable = views.indexOf(view) > 0;
const shouldShowPrevNext2Buttons = view !== 'century';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/CenturyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type CenturyViewProps = React.ComponentProps<typeof Decades>;
/**
* Displays a given century.
*/
export default function CenturyView(props: CenturyViewProps) {
export default function CenturyView(props: CenturyViewProps): React.ReactElement {
function renderDecades() {
return <Decades {...props} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/CenturyView/Decade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function Decade({
currentCentury,
formatYear = defaultFormatYear,
...otherProps
}: DecadeProps) {
}: DecadeProps): React.ReactElement {
const { date, locale } = otherProps;

const classesProps: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/CenturyView/Decades.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type DecadesProps = {
> &
Omit<React.ComponentProps<typeof Decade>, 'classes' | 'currentCentury' | 'date'>;

export default function Decades(props: DecadesProps) {
export default function Decades(props: DecadesProps): React.ReactElement {
const { activeStartDate, hover, showNeighboringCentury, value, valueType, ...otherProps } = props;
const start = getBeginOfCenturyYear(activeStartDate);
const end = start + (showNeighboringCentury ? 119 : 99);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/DecadeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type DecadeViewProps = React.ComponentProps<typeof Years>;
/**
* Displays a given decade.
*/
export default function DecadeView(props: DecadeViewProps) {
export default function DecadeView(props: DecadeViewProps): React.ReactElement {
function renderYears() {
return <Years {...props} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/DecadeView/Year.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Year({
currentDecade,
formatYear = defaultFormatYear,
...otherProps
}: YearProps) {
}: YearProps): React.ReactElement {
const { date, locale } = otherProps;

const classesProps: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/DecadeView/Years.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type YearsProps = {
> &
Omit<React.ComponentProps<typeof Year>, 'classes' | 'currentDecade' | 'date'>;

export default function Years(props: YearsProps) {
export default function Years(props: YearsProps): React.ReactElement {
const { activeStartDate, hover, showNeighboringDecade, value, valueType, ...otherProps } = props;
const start = getBeginOfDecadeYear(activeStartDate);
const end = start + (showNeighboringDecade ? 11 : 9);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Flex({
style,
wrap,
...otherProps
}: FlexProps) {
}: FlexProps): React.ReactElement {
return (
<div
className={className}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/MonthView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type MonthViewProps = {
/**
* Displays a given month.
*/
export default function MonthView(props: MonthViewProps) {
export default function MonthView(props: MonthViewProps): React.ReactElement {
const { activeStartDate, locale, onMouseLeave, showFixedNumberOfWeeks } = props;
const {
calendarType = getCalendarTypeFromLocale(locale),
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/MonthView/Day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Day({
formatDay = defaultFormatDay,
formatLongDate = defaultFormatLongDate,
...otherProps
}: DayProps) {
}: DayProps): React.ReactElement {
const { date, locale } = otherProps;

const classesProps: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/MonthView/Days.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type DaysProps = {
> &
Omit<React.ComponentProps<typeof Day>, 'classes' | 'currentMonthIndex' | 'date' | 'point'>;

export default function Days(props: DaysProps) {
export default function Days(props: DaysProps): React.ReactElement {
const {
activeStartDate,
calendarType,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/MonthView/WeekNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type WeekNumberProps<T = OnClickWeekNumberFunc | undefined> = (T extends OnClick
weekNumber: number;
};

export default function WeekNumber(props: WeekNumberProps) {
export default function WeekNumber(props: WeekNumberProps): React.ReactElement {
const { onClickWeekNumber, weekNumber } = props;

const children = <span>{weekNumber}</span>;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/MonthView/WeekNumbers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type WeekNumbersProps = {
showFixedNumberOfWeeks?: boolean;
};

export default function WeekNumbers(props: WeekNumbersProps) {
export default function WeekNumbers(props: WeekNumbersProps): React.ReactElement {
const { activeStartDate, calendarType, onClickWeekNumber, onMouseLeave, showFixedNumberOfWeeks } =
props;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/MonthView/Weekdays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type WeekdaysProps = {
onMouseLeave?: () => void;
};

export default function Weekdays(props: WeekdaysProps) {
export default function Weekdays(props: WeekdaysProps): React.ReactElement {
const {
calendarType,
formatShortWeekday = defaultFormatShortWeekday,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type TileProps = {
view: View;
};

export default function Tile(props: TileProps) {
export default function Tile(props: TileProps): React.ReactElement {
const {
activeStartDate,
children,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/TileGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function TileGroup({
step = 1,
value,
valueType,
}: TileGroupProps) {
}: TileGroupProps): React.ReactElement {
const tiles = [];
for (let point = start; point <= end; point += step) {
const date = dateTransform(point);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/YearView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type YearViewProps = React.ComponentProps<typeof Months>;
/**
* Displays a given year.
*/
export default function YearView(props: YearViewProps) {
export default function YearView(props: YearViewProps): React.ReactElement {
function renderMonths() {
return <Months {...props} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/YearView/Month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function Month({
formatMonth = defaultFormatMonth,
formatMonthYear = defaultFormatMonthYear,
...otherProps
}: MonthProps) {
}: MonthProps): React.ReactElement {
const { date, locale } = otherProps;

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/YearView/Months.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type MonthsProps = {
> &
Omit<React.ComponentProps<typeof Month>, 'classes' | 'date'>;

export default function Months(props: MonthsProps) {
export default function Months(props: MonthsProps): React.ReactElement {
const { activeStartDate, hover, value, valueType, ...otherProps } = props;
const start = 0;
const end = 11;
Expand Down
24 changes: 16 additions & 8 deletions packages/react-calendar/src/shared/dateFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ const formatShortWeekdayOptions = { weekday: 'short' } satisfies Intl.DateTimeFo
const formatWeekdayOptions = { weekday: 'long' } satisfies Intl.DateTimeFormatOptions;
const formatYearOptions = { year: 'numeric' } satisfies Intl.DateTimeFormatOptions;

export const formatDate = getSafeFormatter(formatDateOptions);
export const formatDay = getSafeFormatter(formatDayOptions);
export const formatLongDate = getSafeFormatter(formatLongDateOptions);
export const formatMonth = getSafeFormatter(formatMonthOptions);
export const formatMonthYear = getSafeFormatter(formatMonthYearOptions);
export const formatShortWeekday = getSafeFormatter(formatShortWeekdayOptions);
export const formatWeekday = getSafeFormatter(formatWeekdayOptions);
export const formatYear = getSafeFormatter(formatYearOptions);
export const formatDate: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatDateOptions);
export const formatDay: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatDayOptions);
export const formatLongDate: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatLongDateOptions);
export const formatMonth: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatMonthOptions);
export const formatMonthYear: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatMonthYearOptions);
export const formatShortWeekday: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatShortWeekdayOptions);
export const formatWeekday: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatWeekdayOptions);
export const formatYear: (locale: string | undefined, date: Date) => string =
getSafeFormatter(formatYearOptions);

0 comments on commit 96ec191

Please sign in to comment.