Skip to content

Commit

Permalink
feat(type-helper): Update type definitions for Dictionary and Json
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Jan 15, 2024
1 parent 6f22995 commit 0e3d56f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/type-helper/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,30 @@ export type Merge<M, N> = Omit<M, keyof N> & N;
/**
* Represents a dictionary object with string keys and values of type T.
*/
export interface Dictionary<T = unknown> {
export interface Dictionary<T = any> {
[key: string | number]: T;
}

/**
* Strigifyable JSON value
* Strigifyable JSON value that can be of type `string`, `number`, `boolean`, `null`, `undefined`,
* `JSONArray`, or `JSONObject`.
*/
export type JsonValue = string | number | boolean | null | undefined | JsonArray | JsonObject;

/**
* Represents a JSON value that can be of type string, number, boolean, null, undefined,
* JSONArray, or JSONObject.
* Represents `Array<JSONValues>`.
*/
export type JSONValue = string | number | boolean | null | undefined | JSONArray | JSONObject;
export type JsonArray = JsonValue[];

/**
* Represents an array of JSONValues.
* Represents an `Dictionary` of `JSONValue` (Record<string, JSONValues>)
*/
type JSONArray = JSONValue[];
export type JsonObject = Dictionary<JsonValue>;

/**
* Represents an object of Record<string, JSONValues>
* Represents a Json response content that can be of type `JSONArray` or `JSONObject`.
*/
type JSONObject = Dictionary<JSONValue>;
export type Json = JsonArray | JsonObject;

/**
* Represents an object that has the ability to add event listeners.
Expand Down

0 comments on commit 0e3d56f

Please sign in to comment.