From b3814c37f6519de7760d313f34a6d61c1db6eb1c Mon Sep 17 00:00:00 2001 From: "E.G. Hornbostel" Date: Tue, 22 Aug 2017 12:44:55 -0700 Subject: [PATCH 1/2] Added options for diffChars and diffWords --- types/diff/index.d.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/types/diff/index.d.ts b/types/diff/index.d.ts index 49975756f4..05b02d2bcd 100644 --- a/types/diff/index.d.ts +++ b/types/diff/index.d.ts @@ -4,10 +4,20 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 + export = JsDiff; export as namespace JsDiff; declare namespace JsDiff { + interface ICaseOptions { + ignoreCase: boolean + } + + interface ILinesOptions { + ignoreWhitespace?: boolean, + newlineIsToken?: boolean + } + interface IDiffResult { value: string; count?: number; @@ -54,18 +64,15 @@ declare namespace JsDiff { tokenize(value: string): any; // return types are string or string[] } - function diffChars(oldStr: string, newStr: string): IDiffResult[]; + function diffChars(oldStr: string, newStr: string, options?: ICaseOptions): IDiffResult[]; - function diffWords(oldStr: string, newStr: string): IDiffResult[]; + function diffWords(oldStr: string, newStr: string, options?: ICaseOptions): IDiffResult[]; function diffWordsWithSpace(oldStr: string, newStr: string): IDiffResult[]; function diffJson(oldObj: object, newObj: object): IDiffResult[]; - function diffLines(oldStr: string, newStr: string, options?: { - ignoreWhitespace?: boolean, - newlineIsToken?: boolean, - }): IDiffResult[]; + function diffLines(oldStr: string, newStr: string, options?: ILinesOptions): IDiffResult[]; function diffCss(oldStr: string, newStr: string): IDiffResult[]; From 9466d1bd2491c513395fadc7ca9dc9c42279cd94 Mon Sep 17 00:00:00 2001 From: "E.G. Hornbostel" Date: Tue, 22 Aug 2017 14:27:05 -0700 Subject: [PATCH 2/2] Fixed tslint errors. --- types/diff/diff-tests.ts | 2 +- types/diff/index.d.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/types/diff/diff-tests.ts b/types/diff/diff-tests.ts index 0d49147c33..e787c44f48 100644 --- a/types/diff/diff-tests.ts +++ b/types/diff/diff-tests.ts @@ -7,7 +7,7 @@ let diff = jsdiff.diffChars(one, other); diff.forEach(part => { const mark = part.added ? '+' : part.removed ? '-' : ' '; - console.log(mark + " " + part.value); + console.log(`${mark} ${part.value}`); }); // -------------------------- diff --git a/types/diff/index.d.ts b/types/diff/index.d.ts index 05b02d2bcd..720a8d3270 100644 --- a/types/diff/index.d.ts +++ b/types/diff/index.d.ts @@ -4,18 +4,17 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 - export = JsDiff; export as namespace JsDiff; declare namespace JsDiff { interface ICaseOptions { - ignoreCase: boolean + ignoreCase: boolean; } interface ILinesOptions { - ignoreWhitespace?: boolean, - newlineIsToken?: boolean + ignoreWhitespace?: boolean; + newlineIsToken?: boolean; } interface IDiffResult {