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

fixed error 'NodeJS.Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

espisepi
Copy link

Problem:

The code was causing a TypeScript error because clearInterval expects an argument of type number | undefined, but this.timerInterval was typed as NodeJS.Timer. This mismatch was causing the following error:

No overload matches this call.
Overload 1 of 2, '(intervalId: string | number | Timeout | undefined): void', gave the following error.
Argument of type 'NodeJS.Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.

Solution:

The issue was resolved by updating the type of timerInterval to NodeJS.Timeout | undefined, which is the correct type for the return value of setInterval in a Node.js environment. This ensures compatibility with clearInterval and eliminates the TypeScript error.

This change ensures that the type of timerInterval is compatible with what clearInterval expects, preventing type errors during compilation.

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

Successfully merging this pull request may close these issues.

1 participant