fix: add support for node 22/24, drop node 16/21#2580
Open
jasoniangreen wants to merge 3 commits intomasterfrom
Open
fix: add support for node 22/24, drop node 16/21#2580jasoniangreen wants to merge 3 commits intomasterfrom
jasoniangreen wants to merge 3 commits intomasterfrom
Conversation
ba66328 to
014e6bb
Compare
Collaborator
Author
|
@epoberezkin I wanted to have another crack at "resolve $dynamicRef to $dynamicAnchor in $defs" but it looks like this is needed first (node 16 build fails on master). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for node 22/24 and drops node 16/21. I did consider if the change to support node 22 should be in ajv config around the
esModuleInteropbut that would change the actual output of the lib whereas this fix only changes test files.Summary
Node 22 introduced native TypeScript type stripping. When
ts-nodeis registered via-r ts-node/register, Node 22's native handler intercepts.tsfiles first and runs in "strip-only" mode, which cannot handleimport = require()syntax — a TypeScript-specific construct. This causesERR_UNSUPPORTED_TYPESCRIPT_SYNTAXon all test runs.This PR:
import X = require("Y")→import * as X from "Y"in 17 spec files (23 occurrences)[16.x, 18.x, 20.x, 21.x]to[18.x, 20.x, 22.x, 24.x]if-node-version 12fromtest-allscript and its dependencyWhy drop Node 16 and 21?
Why
import * asinstead ofimport X from?esModuleInteropis not enabled in the base tsconfig (@ajv-validator/config), soimport X from "Y"would fail for CommonJS modules.import * as X from "Y"is semantically equivalent toimport X = require("Y")when compiling to CommonJS and works across all Node versions without experimental flags.Alternatives considered
NODE_OPTIONS=--no-experimental-strip-types: Would suppress Node's native TS handling, but depends on the flag continuing to existNODE_OPTIONS=--experimental-transform-types: Would enable full TS syntax support in Node, but relies on an experimental flag with unclearts-nodeinteractionRefactoring the imports is the safest, most future-proof approach — zero production code changes, mechanical transformation only in test files.