Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This expression is not callable #75

Closed
albertosantini opened this issue Mar 22, 2022 · 4 comments
Closed

This expression is not callable #75

albertosantini opened this issue Mar 22, 2022 · 4 comments

Comments

@albertosantini
Copy link

Thanks for your efforts. Here replacing cron package with croner.
I saw also PM2 recently migrated to croner. Congrats.

Using croner 4.3.6, with VSCode 1.65.2, I noted this messages in Problems panel:

This expression is not callable.
  Type 'typeof import("[...]/node_modules/croner/types/croner.single")' has no call signatures.

A function with a name starting with an uppercase letter should only be used as a constructor.
const Cron = require("croner");

Cron("1 25 5 * * *", {
    timezone: "Europe/Rome"
}, () => {
    run();
});

Ok, eslint error depends on new-cap setting.
The surprise was about ts lint message

Of course I can suppress the messages with the following directives:

// @ts-ignore
Cron("1 25 5 * * *", { // eslint-disable-line
    timezone: "Europe/Rome"
}, () => {
    run();
});

Any hint?

@Hexagon
Copy link
Owner

Hexagon commented Mar 22, 2022

Will have a look at that until next release! The typescript definitions isn't widely used yet, i think. So all issue reports are appreciated! 👍

@Hexagon
Copy link
Owner

Hexagon commented Mar 22, 2022

@albertosantini I just got an idea, if you use new Cron instead of just Cron, do the message disappear? Cron without new is just a shortcut.

See the TypeScript example just below https://github.com/Hexagon/croner#nodejs

@albertosantini
Copy link
Author

Yes, it is gone but

Do not use 'new' for side effects. due to no-new setting.

Sorry. I have been using a quite strict configuration:
https://github.com/eslint/eslint/blob/main/packages/eslint-config-eslint/default.yml

Resolved with

const cron = require("croner");

// @ts-ignore
cron("1 25 5 * * *", {
    timezone: "Europe/Rome"
}, () => {
    run();
});

@Hexagon
Copy link
Owner

Hexagon commented Mar 22, 2022

Just tested it myself, and this is a tricky one. Will consider changing the interface to support such strict rules from 5.0. But for now, as it works fine with default typescript-eslint rules, I just added a note under https://github.com/Hexagon/croner#installation. Thanks!

@Hexagon Hexagon closed this as completed Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants