From 09aa4778853c3e54298dfb9f10f905f97a850024 Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Tue, 8 Oct 2019 22:17:46 +0800 Subject: [PATCH 1/3] fix(JsonObject): allow all keys to be optional --- source/basic.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/basic.d.ts b/source/basic.d.ts index 5969ce59c..f97553572 100644 --- a/source/basic.d.ts +++ b/source/basic.d.ts @@ -40,7 +40,7 @@ Matches a JSON object. This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`. */ -export type JsonObject = {[key: string]: JsonValue}; +export type JsonObject = {[key: string]?: JsonValue}; /** Matches a JSON array. From a870e29e692eb1f1c91518a154dd7d05aa71383d Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Tue, 8 Oct 2019 23:20:42 +0800 Subject: [PATCH 2/3] fix(JsonObject): syntax error --- source/basic.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/basic.d.ts b/source/basic.d.ts index f97553572..c58914476 100644 --- a/source/basic.d.ts +++ b/source/basic.d.ts @@ -40,7 +40,7 @@ Matches a JSON object. This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`. */ -export type JsonObject = {[key: string]?: JsonValue}; +export type JsonObject = {[key in string]?: JsonValue}; /** Matches a JSON array. From 9b3699d3e5280c18d4a673bf11b41591be6b6fe0 Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Tue, 8 Oct 2019 23:29:54 +0800 Subject: [PATCH 3/3] fix.lint(JsonObject): type parameter --- source/basic.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/basic.d.ts b/source/basic.d.ts index c58914476..d380c8b91 100644 --- a/source/basic.d.ts +++ b/source/basic.d.ts @@ -40,7 +40,7 @@ Matches a JSON object. This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`. */ -export type JsonObject = {[key in string]?: JsonValue}; +export type JsonObject = {[Key in string]?: JsonValue}; /** Matches a JSON array.