Skip to content

Upgrade to TypeScript 6.0 and module: nodenext to remove reference directives#121

Merged
jeremymeng merged 6 commits intoamqp:masterfrom
deyaaeldeen:fix/remove-reference-directives
May 5, 2026
Merged

Upgrade to TypeScript 6.0 and module: nodenext to remove reference directives#121
jeremymeng merged 6 commits intoamqp:masterfrom
deyaaeldeen:fix/remove-reference-directives

Conversation

@deyaaeldeen
Copy link
Copy Markdown
Contributor

@deyaaeldeen deyaaeldeen commented Apr 14, 2026

Upgrade TypeScript from 5.0 to 6.0 and switch module from "commonjs" to "nodenext". This eliminates the auto-generated /// <reference types="node" /> directives from the generated .d.ts files.

Problem

TypeScript 5.x automatically emits /// <reference types="node" /> in .d.ts output when source code imports from Node.js built-in modules ("net", "tls", "events"). These directives inject the entire @types/node global namespace into consumers' type context, causing conflicts in non-Node environments (React Native, browser, Cloudflare Workers).

Solution

TypeScript 6.0 fixed this behavior — it no longer emits redundant reference directives when explicit module imports already exist. Upgrading TypeScript and switching to module: "nodenext" eliminates the directives without any post-processing.

Changes

File Change
package.json typescript ~5.0.4 → ^6.0.2, @types/node ^16.0.0 → ^20.0.0
tsconfig.json module: "commonjs""nodenext", added moduleResolution: "nodenext", added explicit types
lib/log.ts import * as debugModuleimport debugModule (nodenext CJS interop)
lib/awaitableSender.ts NodeJS.TimerReturnType<typeof setTimeout> (deprecated in @types/node@20)
test/*.spec.ts import * as rheaimport rhea (same)
.github/workflows/ci.yml Node matrix [16.x, 18.x, 20.x] → [20.x, 22.x]
README.md Node.js 6.x → 20.x minimum
changelog.md Added 3.0.4 (Unreleased) entry

Results

  • ✅ Zero /// <reference types="node" /> directives in generated typings
  • ✅ Zero lib compilation errors
  • ✅ All 63 tests passing

Related

Fixes #120

Upgrade TypeScript from 5.0 to 6.0 and switch module from 'commonjs' to
'node16'. This eliminates the auto-generated `/// <reference types="node" />`
directives from the generated .d.ts files in typings/.

TypeScript 6.0 no longer emits these redundant directives when source code
uses explicit imports from Node.js built-in modules ('net', 'tls', 'events').
The directives were injecting the entire @types/node global namespace into
consumers' type context, causing conflicts in non-Node environments
(React Native, browser, Cloudflare Workers).

Changes:
- package.json: typescript ~5.0.4 -> ~6.0.2
- tsconfig.json: module 'commonjs' -> 'node16', removed deprecated
  'moduleResolution: node', added explicit types array
- lib/log.ts: import * as debugModule -> import debugModule (required for
  node16 module resolution with CJS packages)
- test/*.spec.ts: import * as rhea -> import rhea (same reason)

All 63 tests pass. Zero lib compilation errors.

Fixes amqp#120
@deyaaeldeen deyaaeldeen force-pushed the fix/remove-reference-directives branch from 126dd2d to 4439f5a Compare April 14, 2026 01:22
@deyaaeldeen deyaaeldeen changed the title Strip /// <reference types="node" /> from generated .d.ts files Upgrade to TypeScript 6.0 and module: node16 to remove reference directives Apr 14, 2026
Comment thread package.json Outdated
deyaaeldeen and others added 3 commits April 20, 2026 11:39
- @types/node ^16.0.0 → ^20.0.0
- CI matrix: [16.x, 18.x, 20.x] → [18.x, 20.x, 22.x]
- Fix NodeJS.Timer → ReturnType<typeof setTimeout> (deprecated in @types/node@20)

TypeScript 6.0 and api-extractor 7.58+ require Node 18+.

Co-authored-by: Copilot <[email protected]>
@deyaaeldeen deyaaeldeen force-pushed the fix/remove-reference-directives branch from f580d02 to 02cceb8 Compare May 5, 2026 16:26
Comment thread tsconfig.json Outdated
Comment thread tsconfig.json
@deyaaeldeen deyaaeldeen force-pushed the fix/remove-reference-directives branch from 5b62b03 to 9c3dd07 Compare May 5, 2026 16:38
@deyaaeldeen deyaaeldeen changed the title Upgrade to TypeScript 6.0 and module: node16 to remove reference directives Upgrade to TypeScript 6.0 and module: nodenext to remove reference directives May 5, 2026
@jeremymeng jeremymeng merged commit 472d655 into amqp:master May 5, 2026
2 checks passed
@deyaaeldeen deyaaeldeen deleted the fix/remove-reference-directives branch May 5, 2026 16:40
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.

Replace /// <reference types="node" /> with explicit import type in typings

2 participants