Skip to content

jsdoc: function param is inferred as implicit any when directly assigned to module.exports #2157

@TkDodo

Description

@TkDodo

Steps to reproduce

Have a look here:

getsentry/sentry@1badd6a#diff-9d3502c4cc3a54cbfe7e32797921d4a8ab00d1bf275d59a6cc4d52b946f0e601R6-R13

Behavior with typescript@5.8

tsc shows no error

Behavior with tsgo

tsgo --version
Version 7.0.0-dev.20251124.1

tsgo --pretty
tests/js/test-balancer/index.js:13:18 - error TS7006: Parameter 'results' implicitly has an 'any' type.

13 module.exports = results => {

workaround

As a workaround, I have extracted the code to a separate function, annotated that and assigned it to module.exports. This works in both tsc and tsgo:

getsentry/sentry@c57752f

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