From c2020a816f2aad5e237ebf89e237011d4eb6e792 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Wed, 21 Jun 2023 14:42:43 +0300 Subject: [PATCH] Spread the Object into Object & Array types --- src/env.ts | 2 +- types/index.d.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/env.ts b/src/env.ts index aaf131e..9aa5190 100644 --- a/src/env.ts +++ b/src/env.ts @@ -7,7 +7,7 @@ export class Env { this.env = entity; } - static get(key: string, defaultValue: any = null): FN.JSON.Object { + static get(key: string, defaultValue: any = null): any { return this.env[key] || defaultValue; } } diff --git a/types/index.d.ts b/types/index.d.ts index da4369e..e111103 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,18 +1,19 @@ export declare namespace JSON { type Value = Date|RegExp|string|number|boolean|null|JSON.Object|any; - type Object = JSON.Value[]|{ [key: string]: JSON.Value; }; + type Object = { [key: string]: JSON.Value; }; + type Array = JSON.Value[]|JSON.Object[]; } export namespace Gossip { - type Response = JSON.Object|JSON.Value; + type Response = JSON.Object|JSON.Array|JSON.Value; type ResponseHandler = (msg: Gossip.Payload) => Promise; type ResponseHandlers = { [topic: string]: ResponseHandler; }; - type Payload = JSON.Object; + type Payload = JSON.Object|JSON.Array|JSON.Value; } export declare namespace WS { type ConnectionID = string; - type Message = JSON.Object|string; + type Message = JSON.Object|JSON.Array|JSON.Value; type Connection = { id: ConnectionID;