From 16d4c437e1f6bcd726e0ba8bc84f0841061d5c8f Mon Sep 17 00:00:00 2001 From: Andrew Moon Date: Sun, 25 Aug 2024 01:59:17 +0900 Subject: [PATCH] typings: provide internal types for wasi bindings PR-URL: https://github.com/nodejs/node/pull/54119 Reviewed-By: Daeyeon Jeong --- typings/globals.d.ts | 2 ++ typings/internalBinding/wasi.d.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 typings/internalBinding/wasi.d.ts diff --git a/typings/globals.d.ts b/typings/globals.d.ts index 8c7ba495cdf26e..0b82dbb2ccb330 100644 --- a/typings/globals.d.ts +++ b/typings/globals.d.ts @@ -15,6 +15,7 @@ import { TimersBinding } from './internalBinding/timers'; import { TypesBinding } from './internalBinding/types'; import { URLBinding } from './internalBinding/url'; import { UtilBinding } from './internalBinding/util'; +import { WASIBinding } from './internalBinding/wasi'; import { WorkerBinding } from './internalBinding/worker'; import { ModulesBinding } from './internalBinding/modules'; @@ -50,6 +51,7 @@ interface InternalBindingMap { types: TypesBinding; url: URLBinding; util: UtilBinding; + wasi: WASIBinding; worker: WorkerBinding; } diff --git a/typings/internalBinding/wasi.d.ts b/typings/internalBinding/wasi.d.ts new file mode 100644 index 00000000000000..5d1cc61b7114be --- /dev/null +++ b/typings/internalBinding/wasi.d.ts @@ -0,0 +1,14 @@ +declare namespace InternalWASIBinding { + type EnvStr = `${string}=${string}` + + class WASI { + constructor(args: string[], env: EnvStr[], preopens: string[], stdio: [stdin: number, stdout: number, stderr: number]) + + _setMemory(memory: WebAssembly.Memory): void; + } +} + +export interface WASIBinding { + WASI: typeof InternalWASIBinding.WASI; +} +