From b50691efed482496e241857921b66b65bec61655 Mon Sep 17 00:00:00 2001 From: Jared Beller <25756846+jbellerb@users.noreply.github.com> Date: Sat, 13 Feb 2021 11:56:56 -0500 Subject: refactor(core): Strongly typed deserialization of JSON ops (#9423) This PR makes json_op_sync/async generic to all Deserialize/Serialize types instead of the loosely-typed serde_json::Value. Since serde_json::Value implements Deserialize/Serialize, very little existing code needs to be updated, however as json_op_sync/async are now generic, type inference is broken in some cases (see cli/build.rs:146). I've found this reduces a good bit of boilerplate, as seen in the updated deno_core examples. This change may also reduce serialization and deserialization overhead as serde has a better idea of what types it is working with. I am currently working on benchmarks to confirm this and I will update this PR with my findings. --- core/lib.deno_core.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/lib.deno_core.d.ts') diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts index f78c6fec2..1efb92dc6 100644 --- a/core/lib.deno_core.d.ts +++ b/core/lib.deno_core.d.ts @@ -10,14 +10,14 @@ declare namespace Deno { /** Send a JSON op to Rust, and synchronously receive the result. */ function jsonOpSync( opName: string, - args: any, + args?: any, ...zeroCopy: Uint8Array[] ): any; /** Send a JSON op to Rust, and asynchronously receive the result. */ function jsonOpAsync( opName: string, - args: any, + args?: any, ...zeroCopy: Uint8Array[] ): Promise; -- cgit v1.2.3