Files
scriptc/tests/corpus/2380-buffer-module-named-import.ts
Chris Tate b5f6b0dc46 Cite patterns, not target projects, across comments and hints
- Lowering rationale names the idiom; one user-facing hint reworded
- Diagnostics snapshot re-pinned to the neutral hint text
2026-07-23 01:18:50 -05:00

13 lines
659 B
TypeScript

// The module spelling of the Buffer global: `import { Buffer } from
// "node:buffer"` resolves through the import alias to the SAME stdlib
// symbol the bare-global lowerings answer for (the pattern's source graph
// carries third-party .d.ts files that import the name this way).
import { Buffer } from "node:buffer";
const b: Buffer = Buffer.from("héllo", "utf8");
console.log(b.toString("hex"));
console.log(b.length, b.readUInt8(0), b.subarray(1, 3).toString("utf8"));
const c = Buffer.alloc(4, 7);
console.log(c.readUInt32BE(0), Buffer.byteLength("héllo"), Buffer.isEncoding("utf8"));
console.log(Buffer.concat([b, c]).length, Buffer.compare(b, c));