kelektiv / node-cron

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

Typescript error TS2380: "get and set accessor must have the same type" on v2.4.3 #692

Closed sheerlox closed 1 year ago

sheerlox commented 1 year ago

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

To fix it, I needed to downgrade back to 2.4.0 version. My current TS version is 4.2.3

Originally posted by @SirAndrii in https://github.com/kelektiv/node-cron/issues/688#issuecomment-1701826729

sheerlox commented 1 year ago

Hey @SirAndrii, I tried reproducing the issue but couldn't get the same error (see sheerlox/node-cron-test).

Please share more information about your setup, especially which other libraries (with versions) you're using on your project.

Have you tried deleting your node_modules and running npm install again? That could maybe solve the issue.

SirAndrii commented 1 year ago

Hey @SirAndrii, I tried reproducing the issue but couldn't get the same error (see sheerlox/node-cron-test).

Please share more information about your setup, especially which other libraries (with versions) you're using on your project.

Have you tried deleting your node_modules and running npm install again? That could maybe solve the issue.

on our project we use YARN. Before installation, I removed all node_module folders and yarn.lock files, so the installation was clean. And I made a mistake about TS, it's 3.8.3

"dependencies": {
    "body-parser": "^1.19.2",
    "cron": "2.4.0",
    "express": "^4.17.3",
    "fs-extra": "^5.0.0",
    "knex": "^0.21.21",
    "multer": "^1.4.4",
    "moment": "^2.29.4",
    "ws": "^3.3.3"
  },
  "devDependencies": {
    "@types/multer": "^1.4.7",
    "jest": "^22.4.3",
    "typescript": "3.8.3"
  },
sheerlox commented 1 year ago

With the packages you shared, I'm getting 147 Typescript errors, none related to cron (and most point to @types/node/ts4.8), whether I'm installing with yarn or npm is the same. I've updated my test repository accordingly if you'd like to take a look.

Since it seems this issue is hard to reproduce, or I am missing some information, could you share a minimal reproduction repository so I can investigate the issue?

But, on the other hand, the issue seems to be related to @types/luxon not being compatible with your Typescript version (which is ~ 4 years old). If you often get this kind of issue it could be interesting to think about upgrading to the latest version of Typescript.

sheerlox commented 1 year ago

Hello @SirAndrii, any update on this? Closing for now since I can't reproduce this bug, feel free to reopen if you can provide more information.