Skip to content

[Bugfix] Model JSON value type properly#226

Open
mike-north wants to merge 1 commit intopretenderjs:masterfrom
mike-north:json-types
Open

[Bugfix] Model JSON value type properly#226
mike-north wants to merge 1 commit intopretenderjs:masterfrom
mike-north:json-types

Conversation

@mike-north
Copy link
Member

@mike-north mike-north commented Jan 11, 2018

The current ambient type definitions are inappropriately constrained here

export type ResponseData = [number, { [k: string]: string }, string];

This would not allow for arrays, or non-string values.

I've made a package containing a "JSON value" type defined as

export type Primitive = string | number | boolean | null;
export interface Object {
	[member: string]: Value;
}
export interface Arr extends Array<Value> {}

export type Value = Primitive | Object | Arr;

that models characteristics of JSON values correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant