react-nice-dates icon indicating copy to clipboard operation
react-nice-dates copied to clipboard

Type error: Module '"react-nice-dates"' has no exported member 'START_DATE'

Open mubasshar009 opened this issue 3 years ago • 3 comments

I am using react-nice-dates in react Typescript,it is work on local host but on deployment its showing error. `

Type error: Module '"react-nice-dates"' has no exported member 'START_DATE'.

21:33:17.966 |   21:33:17.966 | 5 | import { format } from 'date-fns' 21:33:17.967 | 6 | import { enGB } from 'date-fns/locale' 21:33:17.967 | > 7 | import { DateRangePickerCalendar, START_DATE } from 'react-nice-dates' 21:33:17.967 | | ^ 21:33:17.967 | 8 | import 'react-nice-dates/build/style.css' 21:33:17.967 | 9 | import { start } from 'repl'; 21:33:17.967 | 10 | const Search = () => { 21:33:17.988 | error Command failed with exit code 1.

`

mubasshar009 avatar Feb 09 '22 01:02 mubasshar009

Here is a quick solution:

  • Create a file in the root of your project & name it react-nice-dates.d.ts.
  • Put the following types declarations inside it:
declare module 'react-nice-dates' {
  export const START_DATE: string;
  export const END_DATE: string;
}
  • Save the file, then open your tsconfig.json & add the file that we just created to the include entry:
{
   ...,
   "include": [
     ...,
+    "react-nice-dates.d.ts"
   ]
}

AXeL-dev avatar Mar 03 '22 11:03 AXeL-dev

START_DATE and END_DATE boil down to the strings endDate and startDate. Declare these at the top of your file and you should be good.

wolfeaustin avatar Aug 19 '22 22:08 wolfeaustin

the same error !

huanlirui avatar Aug 31 '22 08:08 huanlirui