Skip to content

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.

Notifications You must be signed in to change notification settings

Bashamega/jsconfig-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bug Report: TypeScript Native Preview - Incorrect Argument Count Error for semver.gt

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

  1. Install dependencies as in package.json:
    {
      "devDependencies": {
        "@typescript/native-preview": "^7.0.0-dev.20250804.1"
      },
      "dependencies": {
        "semver": "^7.6.0"
      }
    }
  2. Use the following code in index.js:
    import semver from 'semver';
    
    /** @type {string} */
    const version = '1.2.3';
    
    console.log(semver.gt(version, '1.2.0')); // true
  3. Run: tsgo -p ./jsconfig.json

Actual Behavior

The following Error is produced:```bash

[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`

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published