Skip to content

Incorrect Argument Count Error for optional params when using jsconfig #1521

@Bashamega

Description

@Bashamega

Summary

When using TypeScript Native Preview with a standard ESM setup and the semver package, calling semver.gt with two arguments in a JavaScript file results in a TypeScript error about missing arguments. This does not occur with the same code in other TypeScript environments, suggesting a compatibility issue specific to TypeScript Native Preview.

Environment

  • TypeScript Native Preview: @typescript/[email protected]
  • Node.js: >=20.6.0
  • semver: ^7.6.0
  • jsconfig.json: (using "module": "esnext", "target": "es2020")
  • Repro file: index.js
  • Command: tsgo -p ./jsconfig.json && node ./index.js

Repro Steps

Clone this and run the main command: https://github.com/Bashamega/jsconfig-repro

Actual Behavior

The following Error is produced:

> [email protected] main
> tsgo -p ./jsconfig.json && node ./index.js

index.js:9:20 - error TS2554: Expected 3 arguments, but got 2.

9 console.log(semver.gt(version, '1.2.0')); // true
                     ~~

  node_modules/semver/functions/gt.js:2:19 - An argument for 'loose' was not provided.
    2 const gt = (a, b, loose) => compare(a, b, loose) > 0
                        ~~~~~

Found 1 error in index.js:9

Expected Behavior

It should return true

Originally discovered in:
microsoft/TypeScript-DOM-lib-generator#2104

Metadata

Metadata

Assignees

Labels

Domain: JSRelated to JS parsing, checking

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions