Skip to content

🪧 fix: Resolve SDK Declarations Under Node16 and NodeNext - #738

Merged
danny-avila merged 2 commits into
mainfrom
lia/agents-nodenext-declarations
Nov 23, 2026
Merged

danny-avila merged 2 commits into
mainfrom
lia/agents-nodenext-declarations

Conversation

@lia-by-librechat

Copy link
Copy Markdown
Contributor

Summary

@librechat/agents is "type": "module" but publishes .d.ts files with extensionless relative specifiers. TypeScript consumers on moduleResolution: node16 / nodenext cannot resolve them: root exports such as Run fail with TS2305, and some re-exports degrade to any. bundler consumers are unaffected.

Fixes #684

Fix

  • scripts/fix-dts-extensions.mjs runs at the end of build:types and rewrites relative specifiers in dist/types to .js or /index.js when that declaration exists. Explicit extensions, bare specifiers and targets with no declaration are left alone.
  • config/runtime-package.test.mjs packs the real tarball and typechecks a .mts consumer of the root and the /runtime barrel under both Bundler and NodeNext. @ts-expect-error probes fail if an export becomes any.
  • validate.yml runs the rewriter's unit test (test:declaration-extensions).

The pinned tsc-alias 1.9.7 full-path flags do not fix a declarations-only tree.

Packed consumer, TypeScript 5.5.3

Declarations Bundler NodeNext
Without the rewriter pass fail: TS2305 on Run, toStoredMessage, Providers; 6 unused @ts-expect-error (TS2578) where exports were missing or any
With the rewriter pass pass

Notes

Credit

The declaration-rewriting approach is @tang-ontheway's, from #722. This PR adds the packed-tarball consumer regression and the CI wiring; #722's fork CI is waiting on approval, and its code was not checked out or run here. Maintainers can land either.

Keep the existing declaration emit and alias pass. Normalize emitted relative module specifiers to Node-compatible file and barrel paths.

Follows the declaration-normalization approach proposed by tang-ontheway in #722 for #684.
@lia-by-librechat

Copy link
Copy Markdown
Contributor Author

Head 1fd0c5dea0764aaaa047b1621b9ed009cefcce3a, rebased on main at e1ecea824ba1:

  • cae8af953 test: packed-tarball .mts consumer typechecked under Bundler and NodeNext.
  • 1fd0c5dea fix: build:types rewrites relative declaration specifiers to .js / /index.js; unit test wired into validate.yml.

Run locally on this head (Node 24.16.0, TypeScript 5.5.3): npm run build, test:runtime-package (4/4), test:declaration-extensions (1/1), test:light-entries (18/18), npx tsc --noEmit: all pass. Not run: the Jest suite, ESLint.

@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review the latest head, final review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T16:04:11.596625Z 1fd0c5d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 1fd0c5dea0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila merged commit 814fb92 into main Nov 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Types broken under moduleResolution node16/nodenext: relative imports in published .d.ts files have no extension

2 participants