Conversation
…ypings
Remove the triple-slash directive `/// <reference types="node" />` from all
16 typing files. This directive injects the entire @types/node global namespace
into any TypeScript project that imports rhea, even when compiling for non-Node
targets (React Native, browser, Cloudflare Workers), causing type conflicts.
Many files already use explicit imports from "events" and "net". For files
that use Buffer without an explicit import, add `import type { Buffer } from
"buffer"` — this resolves identically for Node consumers but avoids polluting
the global type namespace.
Fixes amqp#446
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.
Remove the triple-slash directive
/// <reference types="node" />from all 16 typing files intypings/. This directive injects the entire@types/nodeglobal namespace into any TypeScript project that imports rhea, even when compiling for non-Node targets (React Native, browser, Cloudflare Workers), causing type conflicts.What changed
/// <reference types="node" />from all 16.d.tsfilesimport type { Buffer } from "buffer"to the 9 files that useBufferwithout an explicit import (connection.d.ts,frames.d.ts,link.d.ts,message.d.ts,sasl.d.ts,session.d.ts,transport.d.ts,types.d.ts,util.d.ts)import { ... } from "events"/import { ... } from "net"needed no additional changesWhy
The
/// <reference types="node" />is a legacy pattern from beforeimport typeexisted. It pulls in all Node.js type definitions globally, which conflicts with other platform type definitions (e.g.,react-native,lib.dom.d.ts) that define the same globals (FormData,AbortController,Blob, etc.).Using explicit
import typeresolves identically for Node consumers (since@types/nodeprovides the"buffer","events", and"net"modules) but avoids polluting consumers' global type namespace.Validation
tsc --noEmitpasses with zero errorsFixes #446