diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index b64117c23e..480b0ee06c 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. diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs index ad41afadaf..e4a9eb11ca 100644 --- a/cli/tests/integration_tests_lsp.rs +++ b/cli/tests/integration_tests_lsp.rs @@ -318,7 +318,7 @@ fn lsp_hover_unstable_enabled() { "language":"typescript", "value":"function Deno.openPlugin(filename: string): number" }, - "**UNSTABLE**: new API, yet to be vetted.\n\nOpen and initialize a plugin.\n\n```ts\nconst rid = Deno.openPlugin(\"./path/to/some/plugin.so\");\nconst opId = Deno.core.ops()[\"some_op\"];\nconst response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));\nconsole.log(`Response from plugin ${response}`);\n```\n\nRequires `allow-plugin` permission.\n\nThe plugin system is not stable and will change in the future, hence the\nlack of docs. For now take a look at the example\nhttps://github.com/denoland/deno/tree/main/test_plugin" + "**UNSTABLE**: new API, yet to be vetted.\n\nOpen and initialize a plugin.\n\n```ts\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nconst rid = Deno.openPlugin(\"./path/to/some/plugin.so\");\n\n// The Deno.core namespace is needed to interact with plugins, but this is\n// internal so we use ts-ignore to skip type checking these calls.\n// @ts-ignore\nconst {\n op_test_sync,\n op_test_async,\n} = Deno.core.ops();\n\nassert(op_test_sync);\nassert(op_test_async);\n\n// @ts-ignore\nconst result = Deno.core.opSync(\"op_test_sync\");\n\n// @ts-ignore\nconst result = await Deno.core.opAsync(\"op_test_sync\");\n```\n\nRequires `allow-plugin` permission.\n\nThe plugin system is not stable and will change in the future, hence the\nlack of docs. For now take a look at the example\nhttps://github.com/denoland/deno/tree/main/test_plugin" ], "range":{ "start":{