Skip to content

ts-check used with @typedef causes an error on module.exports = ... #1685

@arcanis

Description

@arcanis

Steps to reproduce

// @ts-check

/** @typedef {number} Foo */

module.exports = {};

Behavior with [email protected]

No reported errors:

https://www.typescriptlang.org/play/?ts=5.9.2#code/PTAEAEBcGcFoGMAWBTeBrAUB4AqHFIBPAB2QBNkAzUAbwDsBXAWwCNkAnAX1ADEB7PqBzAsTPmQYAbZADpkAD2J92MUAF5anANwYgA

Behavior with tsgo

index.cjs:5:1 - error TS2309: An export assignment cannot be used in a module with other exported elements.

5 module.exports = {};
  ~~~~~~~~~~~~~~~~~~~


Found 1 error in index.cjs:5

This doesn't appear unless ts-check is set, even if allowJs is set to true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: JSRelated to JS parsing, checkingDomain: Type CheckingRelated to type checking, grammar checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions