-
Notifications
You must be signed in to change notification settings - Fork 465
Description
Version
latest
Steps to reproduce
Repository with minimal reproduction: https://github.com/execveat/ts-jest-node14-compatibility-issue
To reproduce:
- Clone the repository
- Run ./reproduce-bug.sh (requires Docker)
Alternatively, run manually:
docker build -t ts-jest-node14-bug .
docker run --rm ts-jest-node14-bug
The reproduction uses a minimal TypeScript project with basic tests, running on Node 14.21.3 with ts-jest ^29.
Expected behavior
Tests should run successfully, since ts-jest declares support for Node ^14.15.0 in its package.json engines.node field.
Actual behavior
Tests fail immediately with a syntax error:
SyntaxError: Unexpected token '??='
at wrapSafe (internal/modules/cjs/loader.js:1029:16)
at Module._compile (internal/modules/cjs/loader.js:1078:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object.<anonymous> (/app/node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js:12:28)
The error occurs in ts-jest's own code at line 57 of transpilers/typescript/transpile-module.js
where it uses the ??=
(logical nullish assignment) operator which was only introduced in Node.js v15.
Debug log
The error occurs before any tests run, so TS_JEST_LOG
doesn't provide additional information. The issue is that ts-jest uses the ??=
operator, which was only introduced in Node 15, but the library claims to support Node 14.15+.
Additional context
Question for maintainers: Is Node 14 still meant to be supported?
The ??= operator was introduced in Node 15.0.0, but ts-jest's package.json declares "engines": { "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" }
. This creates a contradiction between declared compatibility and actual code requirements.
If Node 14 support has been dropped, the engines.node
field should be updated to reflect this. If Node 14 is still meant to be supported, the ??=
operator usage needs to be replaced with compatible syntax.
Environment
Node version:
v14.21.3
Environment info:
System:
OS: Linux 6.10 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (8) arm64 unknown
Binaries:
Node: 14.21.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 6.14.18 - /usr/local/bin/npm
npmPackages:
jest: ^29 => 29.7.0