From dd79430e42bd3e4bed0db9e61ec296d953fd1f07 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 16 Sep 2021 11:50:27 -0400 Subject: [PATCH] Simpler typings --- utils/GunSmith/GunSmith.js | 8 ++++---- utils/GunSmith/Smith.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/utils/GunSmith/GunSmith.js b/utils/GunSmith/GunSmith.js index a2bf8bae..b13a4001 100644 --- a/utils/GunSmith/GunSmith.js +++ b/utils/GunSmith/GunSmith.js @@ -323,7 +323,7 @@ const forge = () => { /** * @param {string} path * @param {boolean=} afterMap - * @returns {GunT.GUNNode & Smith.GunSmithNode} + * @returns {Smith.GunSmithNode} */ function createReplica(path, afterMap = false) { /** @type {(GunT.Listener|GunT.LoadListener)[]} */ @@ -590,7 +590,7 @@ function createReplica(path, afterMap = false) { let userReplicaCalled = false /** - * @returns {GunT.UserGUNNode & Smith.GunSmithNode} + * @returns {Smith.UserSmithNode} */ function createUserReplica() { if (userReplicaCalled) { @@ -600,7 +600,7 @@ function createUserReplica() { const baseReplica = createReplica('$user') - /** @type {GunT.UserGUNNode & Smith.GunSmithNode} */ + /** @type {Smith.UserSmithNode} */ const completeReplica = { ...baseReplica, get _() { @@ -690,7 +690,7 @@ function createUserReplica() { } /** - * @typedef {GunT.GUNNode & Smith.GunSmithNode & { reforge(): void }} RootNode + * @typedef {Smith.GunSmithNode & { reforge(): void }} RootNode */ /** diff --git a/utils/GunSmith/Smith.ts b/utils/GunSmith/Smith.ts index a5325fee..0fdab762 100644 --- a/utils/GunSmith/Smith.ts +++ b/utils/GunSmith/Smith.ts @@ -3,7 +3,11 @@ */ /// namespace Smith { - export interface GunSmithNode { + export interface GunSmithNode extends GunT.GUNNode { + /** + * @override + */ + get(key: string): GunSmithNode /** * @override */ @@ -11,7 +15,7 @@ namespace Smith { /** * @override */ - set(data: GunT.ValidDataValue, cb?: GunT.Callback): GunT.GUNNode + set(data: GunT.ValidDataValue, cb?: GunT.Callback): GunSmithNode /** * Gun will be restarted to force replication of data * if needed. @@ -32,6 +36,8 @@ namespace Smith { specialThen(): Promise } + export type UserSmithNode = GunSmithNode & GunT.UserGUNNode + export interface PendingPut { cb: GunT.Callback data: GunT.ValidDataValue