mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
feat(ext/ffi): support marking symbols as optional (#18529)
This commit is contained in:
parent
51d3fb78ad
commit
62c5664697
6 changed files with 83 additions and 6 deletions
14
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
14
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -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<T extends ForeignLibraryInterface> = {
|
||||
[K in keyof T]: StaticForeignSymbol<T[K]>;
|
||||
[K in keyof T]: T[K]["optional"] extends true
|
||||
? StaticForeignSymbol<T[K]> | null
|
||||
: StaticForeignSymbol<T[K]>;
|
||||
};
|
||||
|
||||
const brand: unique symbol;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue