Skip to content

[TypeScript] Missing declaration file for react-native-calendar-picker #406

@phuocantd

Description

@phuocantd

🐛 Issue: Could not find a declaration file for module 'react-native-calendar-picker'

Description

When using react-native-calendar-picker in a TypeScript-based React Native project, the following error occurs:

Could not find a declaration file for module 'react-native-calendar-picker'.
'/node_modules/react-native-calendar-picker/CalendarPicker/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/react-native-calendar-picker` if it exists or add a new declaration (.d.ts) file.

Root Cause

  • The library does not ship with built-in TypeScript declarations.
  • The community typings via @types/react-native-calendar-picker appear to be outdated and cause JSX compatibility issues.
  • As a result, TypeScript fails to recognize CalendarPicker as a valid JSX element.

Temporary Workaround

Create a manual type declaration file in your project:

📁 src/@types/react-native-calendar-picker.d.ts

declare module 'react-native-calendar-picker' {
  import { Component } from 'react';
  import { ViewStyle, TextStyle } from 'react-native';

  export interface CalendarPickerProps {
    allowRangeSelection?: boolean;
    onDateChange?: (date: Date, type?: 'START_DATE' | 'END_DATE') => void;
    selectedDayColor?: string;
    selectedStartDate?: Date;
    selectedEndDate?: Date;
    todayBackgroundColor?: string;
    textStyle?: TextStyle;
    selectedDayTextColor?: string;
    width?: number;
    height?: number;
    startFromMonday?: boolean;
    minDate?: Date;
    maxDate?: Date;
  }

  export default class CalendarPicker extends Component<CalendarPickerProps> {}
}

Suggested Fix

It would be great if:

  • The library included its own index.d.ts with declared types
  • Or official types were provided and maintained within the package
  • Or the README acknowledged the manual .d.ts workaround

Environment

  • react-native-calendar-picker: ^8.0.5
  • react-native: 0.75.4
  • typescript: 5.0.4

🙏 Thank you for maintaining this package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions