kelektiv / node-cron

Cron for NodeJS.
MIT License
8.41k stars 621 forks source link

Could not find a declaration file for module 'luxon' #688

Closed vajkayrene closed 1 year ago

vajkayrene commented 1 year ago

Description

The following error message is thrown from the cron module (using Typescript):

node_modules/cron/types/index.d.ts:11:26 - error TS7016: Could not find a declaration file for module 'luxon'. '/api/node_modules/luxon/build/node/luxon.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/luxon` if it exists or add a new declaration (.d.ts) file containing `declare module 'luxon';`

The issue is caused by a missing type definition for the luxon library. The docs for the library states it should be installed as a developer dependency separately for typescript.

Screenshots

Screenshot 2023-08-16 at 11 58 11

Additional information

No response

sheerlox commented 1 year ago

You're absolutely right! Typescript cached a version of @types/luxon on my machines, so I didn't notice that error, thank you for reporting the issue!

vajkayrene commented 1 year ago

You're absolutely right! Typescript cached a version of @types/luxon on my machines, so I didn't notice that error, thank you for reporting the issue!

Yes, I had the same issue. 😄 Typescript cached the library on my local machine and I was scratching my head for 30 minutes about why it fails on the CI/CD server.

sheerlox commented 1 year ago

If we'd add @types/luxon to this project, it would need to be added to the regular dependencies, so it would be installed for all users (even JS ones). The issue is that the package size is 115 kB while cron is only 59.2 kB. Would you find installing the @types/cron package in your development dependencies a good solution until we convert the library to TS? If so I'll update the README to include a section about this.

sheerlox commented 1 year ago

On the other hand luxon is 4.06 MB so I guess adding 115 kB is not the end of the world

vajkayrene commented 1 year ago

If we'd add @types/luxon to this project, it would need to be added to the regular dependencies, so it would be installed for all users (even JS ones). The issue is that the package size is 115 kB while cron is only 59.2 kB. Would you find installing the @types/cron package in your development dependencies a good solution until we convert the library to TS? If so I'll update the README to include a section about this.

I tried to install @types/cron, but the fact is typescript still gives me the original issue. I was able to fix it by installing @types/luxon to my devDependecies.

sheerlox commented 1 year ago

I'm sorry I made a mistake in my message, I meant @types/luxon indeed :sweat_smile: @types/cron is deprecated since we imported their types and now ship them directly within cron.

sheerlox commented 1 year ago

I've made a PR to add @types/luxon to our dependencies, it should be merged soon :) thanks for the heads up!

vajkayrene commented 1 year ago

No problem, thanks for the quick fix!

ncb000gt commented 1 year ago

:tada: This issue has been resolved in version 2.4.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

SirAndrii commented 1 year ago

I've made a PR to add @types/luxon to our dependencies, it should be merged soon :) thanks for the heads up! Hi, after update and clean build I started receiving node_modules/@types/luxon/src/settings.d.ts:27:16 - error TS2380: 'get' and 'set' accessor must have the same type.

27 static get defaultZone(): Zone;



node_modules/@types/luxon/src/settings.d.ts:28:16 - error TS2380: 'get' and 'set' accessor must have the same type.

28     static set defaultZone(zone: Zone | string);
![image](https://github.com/kelektiv/node-cron/assets/24919819/f422c176-4968-4640-a3a7-3b83889d2fe5)

To fix it, I needed to downgrade back to 2.4.0 version. My current TS version is 4.2.3
sheerlox commented 1 year ago

@SirAndrii thanks for reporting on this, let's track this here: https://github.com/kelektiv/node-cron/issues/692

ncb000gt commented 1 year ago

:tada: This issue has been resolved in version 3.0.0-beta.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: