From 6a9aaa633cdb206bab55ab9e7aa33fb8a60cd22b Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sun, 16 Dec 2018 19:36:55 +0100 Subject: [PATCH 1/4] js-yaml: fix types of LoadOptions and DumpOptions --- types/js-yaml/index.d.ts | 50 ++++++++++++++++++---------------- types/js-yaml/js-yaml-tests.ts | 11 +++++--- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/types/js-yaml/index.d.ts b/types/js-yaml/index.d.ts index 1dfa56c5a5..8f891f7ba9 100644 --- a/types/js-yaml/index.d.ts +++ b/types/js-yaml/index.d.ts @@ -39,37 +39,39 @@ export function safeDump(obj: any, opts?: DumpOptions): string; export function dump(obj: any, opts?: DumpOptions): string; export interface LoadOptions { - // string to be used as a file path in error/warning messages. - filename?: string; - // makes the loader to throw errors instead of warnings. - strict?: boolean; - // specifies a schema to use. - schema?: any; - // compatibility with JSON.parse behaviour. + /** string to be used as a file path in error/warning messages. */ + filename?: string; + /** function to call on warning messages. */ + onWarning?(this: null, e: YAMLException): void; + /** specifies a schema to use. */ + schema?: SchemaDefinition; + /** compatibility with JSON.parse behaviour. */ json?: boolean; } export interface DumpOptions { - // indentation width to use (in spaces). + /** indentation width to use (in spaces). */ indent?: number; - // do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. + /** do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. */ skipInvalid?: boolean; - // specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere + /** specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere */ flowLevel?: number; - // Each tag may have own set of styles. - "tag" => "style" map. + /** Each tag may have own set of styles. - "tag" => "style" map. */ styles?: { [x: string]: any; }; - // specifies a schema to use. - schema?: any; - // if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) + /** specifies a schema to use. */ + schema?: SchemaDefinition; + /** if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) */ sortKeys?: boolean | ((a: any, b: any) => number); - // set max line width. (default: 80) + /** set max line width. (default: 80) */ lineWidth?: number; - // if true, don't convert duplicate objects into references (default: false) + /** if true, don't convert duplicate objects into references (default: false) */ noRefs?: boolean; - // if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) + /** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */ noCompatMode?: boolean; - // if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. - // Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false) + /** + * if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. + * Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false). + */ condenseFlow?: boolean; } @@ -90,15 +92,15 @@ export interface SchemaDefinition { include?: Schema[]; } -// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 +/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */ export let FAILSAFE_SCHEMA: Schema; -// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 +/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */ export let JSON_SCHEMA: Schema; -// same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 +/** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */ export let CORE_SCHEMA: Schema; -// all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ +/** all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ */ export let DEFAULT_SAFE_SCHEMA: Schema; -// all supported YAML types. +/** all supported YAML types. */ export let DEFAULT_FULL_SCHEMA: Schema; export let MINIMAL_SCHEMA: Schema; export let SAFE_SCHEMA: Schema; diff --git a/types/js-yaml/js-yaml-tests.ts b/types/js-yaml/js-yaml-tests.ts index 2d67b99192..1c9986f269 100644 --- a/types/js-yaml/js-yaml-tests.ts +++ b/types/js-yaml/js-yaml-tests.ts @@ -58,14 +58,14 @@ loadOpts = { filename: str }; loadOpts = { - strict: bool -}; -loadOpts = { - schema: bool + onWarning(e) { e.stack; } }; loadOpts = { json: bool }; +loadOpts = { + schema: yaml.DEFAULT_SAFE_SCHEMA +}; // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -84,6 +84,9 @@ dumpOpts = { dumpOpts = { schema: value }; +dumpOpts = { + schema: yaml.DEFAULT_FULL_SCHEMA +}; // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- From 769251498cd3cf8fd4025360aeae3cc45582f2fc Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Sun, 16 Dec 2018 22:30:14 +0100 Subject: [PATCH 2/4] use tabs for indent --- types/js-yaml/index.d.ts | 14 +++++++------- types/js-yaml/js-yaml-tests.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/types/js-yaml/index.d.ts b/types/js-yaml/index.d.ts index 8f891f7ba9..876ea82f68 100644 --- a/types/js-yaml/index.d.ts +++ b/types/js-yaml/index.d.ts @@ -40,9 +40,9 @@ export function dump(obj: any, opts?: DumpOptions): string; export interface LoadOptions { /** string to be used as a file path in error/warning messages. */ - filename?: string; - /** function to call on warning messages. */ - onWarning?(this: null, e: YAMLException): void; + filename?: string; + /** function to call on warning messages. */ + onWarning?(this: null, e: YAMLException): void; /** specifies a schema to use. */ schema?: SchemaDefinition; /** compatibility with JSON.parse behaviour. */ @@ -68,10 +68,10 @@ export interface DumpOptions { noRefs?: boolean; /** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */ noCompatMode?: boolean; - /** - * if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. - * Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false). - */ + /** + * if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. + * Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false). + */ condenseFlow?: boolean; } diff --git a/types/js-yaml/js-yaml-tests.ts b/types/js-yaml/js-yaml-tests.ts index 1c9986f269..d3d90131d1 100644 --- a/types/js-yaml/js-yaml-tests.ts +++ b/types/js-yaml/js-yaml-tests.ts @@ -64,7 +64,7 @@ loadOpts = { json: bool }; loadOpts = { - schema: yaml.DEFAULT_SAFE_SCHEMA + schema: yaml.DEFAULT_SAFE_SCHEMA }; // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -85,7 +85,7 @@ dumpOpts = { schema: value }; dumpOpts = { - schema: yaml.DEFAULT_FULL_SCHEMA + schema: yaml.DEFAULT_FULL_SCHEMA }; // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- From a8c0a7fb6c346f5cd81364c29bb32579dc65f5c8 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Mon, 17 Dec 2018 08:45:36 +0100 Subject: [PATCH 3/4] switch back to singleline comments --- types/js-yaml/index.d.ts | 42 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/types/js-yaml/index.d.ts b/types/js-yaml/index.d.ts index 876ea82f68..b4aa6e1ec0 100644 --- a/types/js-yaml/index.d.ts +++ b/types/js-yaml/index.d.ts @@ -39,39 +39,37 @@ export function safeDump(obj: any, opts?: DumpOptions): string; export function dump(obj: any, opts?: DumpOptions): string; export interface LoadOptions { - /** string to be used as a file path in error/warning messages. */ + // string to be used as a file path in error/warning messages. filename?: string; - /** function to call on warning messages. */ + // function to call on warning messages. onWarning?(this: null, e: YAMLException): void; - /** specifies a schema to use. */ + // specifies a schema to use. schema?: SchemaDefinition; - /** compatibility with JSON.parse behaviour. */ + // compatibility with JSON.parse behaviour. json?: boolean; } export interface DumpOptions { - /** indentation width to use (in spaces). */ + // indentation width to use (in spaces). indent?: number; - /** do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. */ + // do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. skipInvalid?: boolean; - /** specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere */ + // specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere flowLevel?: number; - /** Each tag may have own set of styles. - "tag" => "style" map. */ + // Each tag may have own set of styles. - "tag" => "style" map. styles?: { [x: string]: any; }; - /** specifies a schema to use. */ + // specifies a schema to use. schema?: SchemaDefinition; - /** if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) */ + // if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) sortKeys?: boolean | ((a: any, b: any) => number); - /** set max line width. (default: 80) */ + // set max line width. (default: 80) lineWidth?: number; - /** if true, don't convert duplicate objects into references (default: false) */ + // if true, don't convert duplicate objects into references (default: false) noRefs?: boolean; - /** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */ + // if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) noCompatMode?: boolean; - /** - * if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. - * Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false). - */ + // if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. + // Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false). condenseFlow?: boolean; } @@ -92,15 +90,15 @@ export interface SchemaDefinition { include?: Schema[]; } -/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */ +// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 export let FAILSAFE_SCHEMA: Schema; -/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */ +// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 export let JSON_SCHEMA: Schema; -/** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */ +// same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 export let CORE_SCHEMA: Schema; -/** all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ */ +// all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ export let DEFAULT_SAFE_SCHEMA: Schema; -/** all supported YAML types. */ +// all supported YAML types. export let DEFAULT_FULL_SCHEMA: Schema; export let MINIMAL_SCHEMA: Schema; export let SAFE_SCHEMA: Schema; From eb83973d6fd3df5516e90102707327ff31065dbd Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Mon, 17 Dec 2018 08:47:17 +0100 Subject: [PATCH 4/4] remove extra whitespace --- types/js-yaml/index.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/types/js-yaml/index.d.ts b/types/js-yaml/index.d.ts index b4aa6e1ec0..20bb5fabc1 100644 --- a/types/js-yaml/index.d.ts +++ b/types/js-yaml/index.d.ts @@ -39,34 +39,34 @@ export function safeDump(obj: any, opts?: DumpOptions): string; export function dump(obj: any, opts?: DumpOptions): string; export interface LoadOptions { - // string to be used as a file path in error/warning messages. + // string to be used as a file path in error/warning messages. filename?: string; - // function to call on warning messages. + // function to call on warning messages. onWarning?(this: null, e: YAMLException): void; - // specifies a schema to use. + // specifies a schema to use. schema?: SchemaDefinition; - // compatibility with JSON.parse behaviour. + // compatibility with JSON.parse behaviour. json?: boolean; } export interface DumpOptions { - // indentation width to use (in spaces). + // indentation width to use (in spaces). indent?: number; - // do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. + // do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. skipInvalid?: boolean; - // specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere + // specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere flowLevel?: number; - // Each tag may have own set of styles. - "tag" => "style" map. + // Each tag may have own set of styles. - "tag" => "style" map. styles?: { [x: string]: any; }; - // specifies a schema to use. + // specifies a schema to use. schema?: SchemaDefinition; - // if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) + // if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) sortKeys?: boolean | ((a: any, b: any) => number); - // set max line width. (default: 80) + // set max line width. (default: 80) lineWidth?: number; - // if true, don't convert duplicate objects into references (default: false) + // if true, don't convert duplicate objects into references (default: false) noRefs?: boolean; - // if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) + // if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) noCompatMode?: boolean; // if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`. // Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false). @@ -90,15 +90,15 @@ export interface SchemaDefinition { include?: Schema[]; } -// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 +// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 export let FAILSAFE_SCHEMA: Schema; -// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 +// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 export let JSON_SCHEMA: Schema; -// same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 +// same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 export let CORE_SCHEMA: Schema; -// all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ +// all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ export let DEFAULT_SAFE_SCHEMA: Schema; -// all supported YAML types. +// all supported YAML types. export let DEFAULT_FULL_SCHEMA: Schema; export let MINIMAL_SCHEMA: Schema; export let SAFE_SCHEMA: Schema;