Skip to content

Async functions define unused parameter #6235

Closed
@CarlOlson

Description

@CarlOlson

Given:

let x = async () => ()

Actual:

async function x(param) {}

Expected:

async function x() {}

I'd consider this a bug. While it shouldn't matter, some libraries try to be too clever and cause issues. Jest is one example I found:

  ● Simple_Test › async props

    thrown: "Exceeded timeout of 5000 ms for a test while waiting for `done()` to be called.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

    > 11 |         test("async props", (async function (param) {

I don't use it, but I think Angular would be another example. They check function parameters for dependency injection.


Found the source:

https://github.com/rescript-lang/rescript-compiler/blob/654fa489f9b02c922cc4393ae076cda6dcdc49f0/jscomp/ml/typecore.ml#L2932-L2938

Changing param will change the output parameter name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions