We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4eb855e commit 3dd85c2Copy full SHA for 3dd85c2
runtime/fundamentals/node.md
@@ -574,6 +574,18 @@ import { Buffer } from "node:buffer";
574
const buf = new Buffer(5, "0");
575
```
576
577
+For TypeScript users needing Node.js-specific types like `BufferEncoding`, these
578
+are available through the `NodeJS` namespace when using `@types/node`:
579
+
580
+```ts title="buffer-types.ts"
581
+/// <reference types="npm:@types/node" />
582
583
+// Now you can use NodeJS namespace types
584
+function writeToBuffer(data: string, encoding: NodeJS.BufferEncoding): Buffer {
585
+ return Buffer.from(data, encoding);
586
+}
587
+```
588
589
Prefer using
590
[`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
591
or other
0 commit comments