mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Without @types/node, every program loaded scriptc-node-fallback.d.ts whole: the console and process globals and 47 Node modules, about 8,100 lines, parsed, bound and checked in every cold build whether or not the program imported them. - The fallback file keeps the globals and the modules they name (console, readline, readline/promises, perf_hooks, tty). Every other module, under both spellings, has its own file in ambient/node-fallback/, which references the files of the modules its declarations name. - A module's file joins the program when one of the program's files names the module in a string literal: imports, requires, import types and JSDoc types all name modules that way. The entry is read before the first program; the program-root discovery passes add modules that other files name. Files are read as tsgo reads them, and the TypeScript libraries and scriptc's own declarations are skipped. - The checks that recognized the fallback file by its path recognize every fallback file.
24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
/* node:buffer — the module spelling of the Buffer/atob/btoa globals.
|
|
* Buffer re-exports the GLOBAL declaration, so an imported binding
|
|
* resolves to the same symbol the lowerings already answer for (and
|
|
* third-party .d.ts files that `import { Buffer } from "node:buffer"` —
|
|
* file-entry-cache in a typed-JS source graph — typecheck). */
|
|
declare module "buffer" {
|
|
export function isAscii(input: ArrayBuffer | ArrayBufferView): boolean;
|
|
export function isUtf8(input: ArrayBuffer | ArrayBufferView): boolean;
|
|
export function transcode(source: Uint8Array, fromEncoding: string, toEncoding: string): Buffer;
|
|
export function atob(data: string): string;
|
|
export function btoa(data: string): string;
|
|
export const kMaxLength: number;
|
|
export const kStringMaxLength: number;
|
|
export const Buffer: BufferConstructor;
|
|
export type Blob = globalThis.Blob;
|
|
export type File = globalThis.File;
|
|
export const Blob: typeof globalThis.Blob;
|
|
export const File: typeof globalThis.File;
|
|
}
|
|
|
|
declare module "node:buffer" {
|
|
export * from "buffer";
|
|
}
|