Upgrade to TypeScript 6.0 and module: nodenext to remove reference directives#121
Merged
jeremymeng merged 6 commits intoamqp:masterfrom May 5, 2026
Merged
Conversation
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
126dd2d to
4439f5a
Compare
/// <reference types="node" /> from generated .d.ts files
jeremymeng
reviewed
Apr 20, 2026
- @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]>
Co-authored-by: Copilot <[email protected]>
f580d02 to
02cceb8
Compare
jeremymeng
reviewed
May 5, 2026
jeremymeng
reviewed
May 5, 2026
Co-authored-by: Copilot <[email protected]>
5b62b03 to
9c3dd07
Compare
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.
Upgrade TypeScript from 5.0 to 6.0 and switch
modulefrom"commonjs"to"nodenext". This eliminates the auto-generated/// <reference types="node" />directives from the generated.d.tsfiles.Problem
TypeScript 5.x automatically emits
/// <reference types="node" />in.d.tsoutput when source code imports from Node.js built-in modules ("net","tls","events"). These directives inject the entire@types/nodeglobal 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
package.jsontypescript~5.0.4 → ^6.0.2,@types/node^16.0.0 → ^20.0.0tsconfig.jsonmodule: "commonjs"→"nodenext", addedmoduleResolution: "nodenext", added explicittypeslib/log.tsimport * as debugModule→import debugModule(nodenext CJS interop)lib/awaitableSender.tsNodeJS.Timer→ReturnType<typeof setTimeout>(deprecated in @types/node@20)test/*.spec.tsimport * as rhea→import rhea(same).github/workflows/ci.ymlREADME.mdchangelog.mdResults
/// <reference types="node" />directives in generated typingsRelated
/// <reference types="node" />with explicitimport typein typings rhea#446 / Replace/// <reference types="node" />with explicitimport typein typings rhea#447 — same fix for therheapackage (hand-written typings)Fixes #120