diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-05-19 21:07:10 +0800 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2021-05-31 16:37:30 +0200 |
commit | 736ff290b8780f76fb0f01ede0c9b704bb8bc3a1 (patch) | |
tree | b0fbde44ccd69b458f7c5505334f862ab5fb3fbe /cli/dts | |
parent | 218ba031f06919b1871b4d360e5ae6c5cc777f35 (diff) |
docs(cli/dts): fix plugin example (#10647)
Diffstat (limited to 'cli/dts')
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index b64117c23..480b0ee06 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -133,10 +133,25 @@ declare namespace Deno { * Open and initialize a plugin. * * ```ts + * import { assert } from "https://deno.land/std/testing/asserts.ts"; * const rid = Deno.openPlugin("./path/to/some/plugin.so"); - * const opId = Deno.core.ops()["some_op"]; - * const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4])); - * console.log(`Response from plugin ${response}`); + * + * // The Deno.core namespace is needed to interact with plugins, but this is + * // internal so we use ts-ignore to skip type checking these calls. + * // @ts-ignore + * const { + * op_test_sync, + * op_test_async, + * } = Deno.core.ops(); + * + * assert(op_test_sync); + * assert(op_test_async); + * + * // @ts-ignore + * const result = Deno.core.opSync("op_test_sync"); + * + * // @ts-ignore + * const result = await Deno.core.opAsync("op_test_sync"); * ``` * * Requires `allow-plugin` permission. |