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.
- 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
- Install dependencies as in
package.json
:{ "devDependencies": { "@typescript/native-preview": "^7.0.0-dev.20250804.1" }, "dependencies": { "semver": "^7.6.0" } }
- 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
- Run:
tsgo -p ./jsconfig.json
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`