From 62c566469710ba610df764df0ee6560295532e4b Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Tue, 4 Apr 2023 00:02:21 +0530 Subject: feat(ext/ffi): support marking symbols as optional (#18529) --- cli/tsc/dts/lib.deno.unstable.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'cli/tsc') diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index b82a80382..4bc0fed45 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -271,6 +271,11 @@ declare namespace Deno { * * @default {false} */ callback?: boolean; + /** When `true`, dlopen will not fail if the symbol is not found. + * Instead, the symbol will be set to `null`. + * + * @default {false} */ + optional?: boolean; } /** **UNSTABLE**: New API, yet to be vetted. @@ -282,6 +287,11 @@ declare namespace Deno { name?: string; /** The type of the foreign static value. */ type: Type; + /** When `true`, dlopen will not fail if the symbol is not found. + * Instead, the symbol will be set to `null`. + * + * @default {false} */ + optional?: boolean; } /** **UNSTABLE**: New API, yet to be vetted. @@ -336,7 +346,9 @@ declare namespace Deno { * @category FFI */ type StaticForeignLibraryInterface = { - [K in keyof T]: StaticForeignSymbol; + [K in keyof T]: T[K]["optional"] extends true + ? StaticForeignSymbol | null + : StaticForeignSymbol; }; const brand: unique symbol; -- cgit v1.2.3