vydimitrov / react-countdown-circle-timer

Lightweight React/React Native countdown timer component with color and progress animation based on SVG
MIT License
692 stars 87 forks source link

Faulty TypeScript Types #56

Closed nlindroos closed 4 years ago

nlindroos commented 4 years ago

Hi!

"react-native-countdown-circle-timer": "2.3.9",

react-native-countdown-circle-timer/types/CountdownCircleTimer.d.ts contains the line

import { Config } from 'use-elapsed-time'

This presumably refers to the use-elapsed-time package. This package is not included as a dependency in react-native-countdown-circle-timer/package.json, which causes TypeScript to emit the error Cannot find module 'use-elapsed-time' or its corresponding type declarations. ts(2307).

nlindroos commented 4 years ago

To make TypeScript compilation work, this can be temporarily bypassed with e.g. the following patch, using patch-package:

// patches/react-native-countdown-circle-timer+2.3.9.patch

diff --git a/node_modules/react-native-countdown-circle-timer/types/CountdownCircleTimer.d.ts b/node_modules/react-native-countdown-circle-timer/types/CountdownCircleTimer.d.ts
index ee7e758..e37afec 100644
--- a/node_modules/react-native-countdown-circle-timer/types/CountdownCircleTimer.d.ts
+++ b/node_modules/react-native-countdown-circle-timer/types/CountdownCircleTimer.d.ts
@@ -1,7 +1,4 @@
 import * as React from 'react'
-import { Config } from 'use-elapsed-time'
-
-export type OnComplete = Config['onComplete']

 export interface TimeProps {
   remainingTime?: number
@@ -48,7 +45,7 @@ export interface CountdownCircleTimerProps {
    * and second element "delay" specifies the delay before looping again in milliseconds.
    *
    */
-  onComplete?: OnComplete
+  onComplete?: any
   /** Aria label for the whole component. Default: "Countdown timer" */
   ariaLabel?: string
   /** Render prop function to customize the text message that will be read by the screen reader during the countdown */
vydimitrov commented 4 years ago

Hey @nlindroos, thanks for reporting this issue. It is now fixed in 2.3.10 👍

nlindroos commented 4 years ago

Thank you @vydimitrov for the quick response and fix!