From 97ca4f14ed97ce40d5954796bc0bd645b68d2e1e Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 19 Mar 2018 10:59:34 -0700 Subject: [PATCH] got tests running, fix up types --- types/js-yaml/index.d.ts | 8 ++++++-- types/js-yaml/js-yaml-tests.ts | 24 ++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/types/js-yaml/index.d.ts b/types/js-yaml/index.d.ts index da745e5d26..5cd852ab3f 100644 --- a/types/js-yaml/index.d.ts +++ b/types/js-yaml/index.d.ts @@ -28,8 +28,12 @@ export class Schema implements SchemaDefinition { static create(schemas: Schema[] | Schema, types: Type[] | Type): Schema; } -export function safeLoadAll(str: string, iterator?: (doc: any) => void, opts?: LoadOptions): DocumentLoadResult[] | undefined; -export function loadAll(str: string, iterator?: (doc: any) => void, opts?: LoadOptions): DocumentLoadResult[] | undefined; +export function safeLoadAll(str: string, iterator?: undefined, opts?: LoadOptions): DocumentLoadResult[]; +export function safeLoadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): undefined; + +export function loadAll(str: string, iterator?: undefined, opts?: LoadOptions): DocumentLoadResult[]; + +export function loadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): undefined; export function safeDump(obj: any, opts?: DumpOptions): string; export function dump(obj: any, opts?: DumpOptions): string; diff --git a/types/js-yaml/js-yaml-tests.ts b/types/js-yaml/js-yaml-tests.ts index 3d5ecc17bf..9a61da204f 100644 --- a/types/js-yaml/js-yaml-tests.ts +++ b/types/js-yaml/js-yaml-tests.ts @@ -109,40 +109,44 @@ type.styleAliases; // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -// $ExpectType any +// $ExpectType DocumentLoadResult yaml.safeLoad(str); -// $ExpectType any +// $ExpectType DocumentLoadResult yaml.safeLoad(str, loadOpts); -// $ExpectType any +// $ExpectType DocumentLoadResult yaml.load(str); -// $ExpectType any +// $ExpectType DocumentLoadResult yaml.load(str, loadOpts); // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -// $ExpectType any +// $ExpectType DocumentLoadResult[] yaml.safeLoadAll(str); -// $ExpectType any + +// $ExpectType undefined yaml.safeLoadAll(str, (doc) => { value = doc; }); -// $ExpectType any +// $ExpectType undefined yaml.safeLoadAll(str, (doc) => { value = doc; }, loadOpts); +// $ExpectType DocumentLoadResult[] value = yaml.safeLoadAll(str, undefined, loadOpts); -// $ExpectType any +// $ExpectType DocumentLoadResult[] value = yaml.loadAll(str); -// $ExpectType any + +// $ExpectType undefined yaml.loadAll(str, (doc) => { value = doc; }); -// $ExpectType any +// $ExpectType undefined yaml.loadAll(str, (doc) => { value = doc; }, loadOpts); +// $ExpectType DocumentLoadResult[] value = yaml.loadAll(str, undefined, loadOpts); // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --