-
Notifications
You must be signed in to change notification settings - Fork 5
feat(types): migrate test suite and config files to TypeScript (Phase 6) #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8b2ad0a
feat(types): migrate test suite and config files to TypeScript (Phase 6)
carlos-alm 7d77811
feat(types): migrate scripts and docs examples to TypeScript
carlos-alm 476e642
feat(types): drop Node 20, require Node >= 22
carlos-alm 8cfb084
fix(ci): update embedding regression workflow to reference .ts test f…
carlos-alm 5c50b2a
Merge remote-tracking branch 'origin/main' into review-588
carlos-alm a6b8f2e
fix: tighten Node engines to >=22.6, restore strip-types guard, use r…
carlos-alm 04a2e50
fix(docs): use version-aware strip-types flag in pre-commit example (…
carlos-alm 57bcfaf
fix(types): add TypeScript parameter types to test helpers (#588)
carlos-alm a21a419
fix(hooks): convert pre-commit-checks.ts from CJS require() to ESM im…
carlos-alm 563de54
fix(ci): add --import loader to benchmark workflow for Node 22 compat…
carlos-alm 9b8eef1
fix: version-aware strip-types flag in benchmark.yml, update docs (#588)
carlos-alm 966ec3e
fix: remove unused .ts loader duplicates (#588)
carlos-alm f19aec9
Revert "fix: remove unused .ts loader duplicates (#588)"
carlos-alm 39d07f1
fix(ci): use version-aware strip-types flag in verify-imports step (#…
carlos-alm d5f30c7
fix(ci): use dynamic strip-types flag in publish workflow (#588)
carlos-alm 83f2633
fix: remove dead scripts/test.js (#588)
carlos-alm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,5 +7,5 @@ docs/ | |
| *.db | ||
| .codegraphrc.json | ||
| .versionrc.json | ||
| commitlint.config.js | ||
| commitlint.config.ts | ||
| codegraph-improvements.md | ||
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
File renamed without changes.
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * ESM resolve hook — rewrites .js specifiers to .ts when the .js file | ||
| * does not exist on disk. Needed because TypeScript's moduleResolution | ||
| * "nodenext" convention uses .js extensions in imports, but at runtime | ||
| * the source files are .ts. | ||
| * | ||
| * Loaded via module.register() from ts-resolve-loader.ts. | ||
| */ | ||
|
|
||
| import { existsSync } from 'node:fs'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| export async function resolve( | ||
| specifier: string, | ||
| context: { parentURL?: string; conditions: string[] }, | ||
| nextResolve: (specifier: string, context?: { parentURL?: string; conditions: string[] }) => Promise<{ url: string; shortCircuit?: boolean }>, | ||
| ): Promise<{ url: string; shortCircuit?: boolean }> { | ||
| try { | ||
| return await nextResolve(specifier, context); | ||
| } catch (err: any) { | ||
| // Only attempt .js → .ts fallback for file-relative specifiers | ||
| if (err?.code === 'ERR_MODULE_NOT_FOUND' && specifier.endsWith('.js')) { | ||
| const tsSpecifier = specifier.slice(0, -3) + '.ts'; | ||
| return nextResolve(tsSpecifier, context); | ||
| } | ||
| throw err; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /** | ||
| * Registers the .js → .ts ESM resolve hook. | ||
| * | ||
| * Usage: node --experimental-strip-types --import ./scripts/ts-resolve-loader.ts src/cli.ts | ||
| */ | ||
|
|
||
| import { register } from 'node:module'; | ||
|
|
||
| register(new URL('./ts-resolve-hooks.ts', import.meta.url)); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--experimental-strip-typesacross all npm scriptsEvery user-facing npm script that invokes a
.tsfile still hardcodes--experimental-strip-types, which is deprecated on Node 23+. The same pattern was flagged and fixed inbenchmark.yml,pre-commit.sh, andvitest.config.ts, butpackage.jsonwas left behind.Affected scripts:
build:wasm(line 33) — runs viaprepare, i.e. on everynpm installverify-imports(line 35)deps:tree(line 45)version(line 48)Users on Node 23+ will see a deprecation warning for every invocation. Because
build:wasmis part of thepreparelifecycle, the warning appears onnpm install, which is the noisiest possible place.package.jsonscripts can't use shell conditionals inline, but a tiny wrapper (similar to the now-unusedscripts/test.js, which already did version-aware flag selection) or an env-var trick works:Alternatively, since
scripts/test.jsalready contains version-aware flag selection logic and is now dead code (package.json replacednode scripts/test.js runwithvitest rundirectly), that pattern could be extracted into a smallscripts/node-ts.jslauncher that accepts a script path as its first argument and applies the correct flag.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed this is a real forward-compatibility concern. However, fixing this in package.json requires creating a new launcher script and changing all four script invocations, which is a meaningful refactor beyond this PR's scope.
Created #590 to track this. The engines constraint (
>=22.6) means this will surface as deprecation warnings (not errors) when users adopt Node 23+, andbuild:wasmduringnpm installis indeed the noisiest place for it.