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

fix: setTimeout and co. have too strict types #5412

Merged
merged 1 commit into from May 15, 2020

Conversation

tkgalk
Copy link
Contributor

@tkgalk tkgalk commented May 14, 2020

Should fix #5278 by moving unknown[] to any[] to line up with TypeScript's behaviour.

Code:

setTimeout((x: number) => {
    console.log("test");
}, 0, 1);

Shouldn't be getting this error anymore:

error: TS2345 [ERROR]: Argument of type '(x: number) => void' is not assignable to parameter of type '(...args: unknown[]) => void'.
  Types of parameters 'x' and 'args' are incompatible.
    Type 'unknown' is not assignable to type 'number'.
setTimeout((x: number) => {
           ~~~~~~~~~~~~~~~~

image

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks @galkowskit

@ry ry merged commit 8440d76 into denoland:master May 15, 2020
@tkgalk tkgalk deleted the fix-setTimeout-and-friends-too-strict branch May 21, 2020 07:05
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
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.

Deno's types for setTimeout and friends are too strict
3 participants