summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index ce609736b..9e91c8800 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -443,7 +443,7 @@ declare namespace Deno {
/** The definition of the function. */
definition: Fn;
- constructor(pointer: PointerValue, definition: Fn);
+ constructor(pointer: PointerValue, definition: Const<Fn>);
/** Call the foreign function. */
call: FromForeignFunction<Fn>;
@@ -494,7 +494,7 @@ declare namespace Deno {
Definition extends UnsafeCallbackDefinition = UnsafeCallbackDefinition,
> {
constructor(
- definition: Definition,
+ definition: Const<Definition>,
callback: UnsafeCallbackFunction<
Definition["parameters"],
Definition["result"]
@@ -562,6 +562,17 @@ declare namespace Deno {
close(): void;
}
+ /**
+ * This magic code used to implement better type hints for {@linkcode Deno.dlopen}
+ */
+ type Cast<A, B> = A extends B ? A : B;
+ type Const<T> = Cast<
+ T,
+ | (T extends string | number | bigint | boolean ? T : never)
+ | { [K in keyof T]: Const<T[K]> }
+ | []
+ >;
+
/** **UNSTABLE**: New API, yet to be vetted.
*
* Opens an external dynamic library and registers symbols, making foreign
@@ -611,7 +622,7 @@ declare namespace Deno {
*/
export function dlopen<S extends ForeignLibraryInterface>(
filename: string | URL,
- symbols: S,
+ symbols: Const<S>,
): DynamicLibrary<S>;
/** **UNSTABLE**: New API, yet to be vetted.