spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.97k stars 184 forks source link

[Typescript] Could not find declaration file for module 'spacetime' #381

Closed the-sky-is-pink closed 1 year ago

the-sky-is-pink commented 1 year ago

Hey there , I used react-timezone-select and writing test cases for the same , but i got this issue==>

****/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Spacetime from './spacetime.js'
   SyntaxError: Cannot use import statement outside a module

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
  at Object.<anonymous> (node_modules/react-timezone-select/dist/index.cjs:38:32)

Can anyone help with this, how can i run the test case with this issue?

spencermountain commented 1 year ago

hi @the-sky-is-pink - i would make sure my package.json has "type": "module". That should tell node to expect import statements. I'm not sure how jest works - there may be a config for supporting esmodules. cheers