Skip to content

Commit

Permalink
Fix missing setOptions arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dodge committed May 2, 2018
1 parent 2421842 commit c326abb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
14 changes: 9 additions & 5 deletions types/ace-diff/ace-diff-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import AceDiff = require('ace-diff');

new AceDiff(); // $ExpectError

const aceDiffOpts = {
const aceDiffConstructorOpts = {
element: '.acediff',
left: { content: 'left content' },
right: { content: 'left content' },
right: { content: 'right content' },
};
new AceDiff(aceDiffOpts); // $ExpectType AceDiff
new AceDiff(aceDiffConstructorOpts); // $ExpectType AceDiff

const differ = new AceDiff(aceDiffOpts);
const differ = new AceDiff(aceDiffConstructorOpts);

differ.getEditors(); // $ExpectType { left: any; right: any; }
differ.setOptions(); // $ExpectType void
differ.setOptions(); // $ExpectError
const aceDiffOpts = {
diffGranularity: 'broad' as 'broad', // workaround: cast to avoid https://github.com/Microsoft/TypeScript/issues/11465#issuecomment-252453037
};
differ.setOptions(aceDiffOpts); // $ExpectType void
differ.getNumDiffs(); // $ExpectType number
differ.diff(); // $ExpectType void
differ.destroy(); // $ExpectType void
15 changes: 10 additions & 5 deletions types/ace-diff/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export as namespace AceDiff;
export = AceDiff;

declare class AceDiff {
constructor(opts: AceDiff.AceDiffOpts);
constructor(opts: AceDiff.AceDiffConstructorOpts);
getEditors(): {
left: any;
right: any;
};
setOptions(): void;
setOptions(options: AceDiff.AceDiffOpts): void;
getNumDiffs(): number;
diff(): void;
destroy(): void;
Expand All @@ -27,16 +27,21 @@ declare namespace AceDiff {
copyLinkEnabled?: boolean;
}

interface AceDiffOpts {
interface AceDiffConstructorOpts extends AceDiffOpts {
element: string | HTMLElement;
left: AceDiffLROpts;
right: AceDiffLROpts;
}

interface AceDiffOpts {
mode?: string;
theme?: string;
diffGranularity?: 'specific' | 'broad';
showDiffs?: boolean;
showConnectors?: boolean;
maxDiffs?: number;
left: AceDiffLROpts;
right: AceDiffLROpts;
left?: AceDiffLROpts;
right?: AceDiffLROpts;
classes?: {
diff: string;
connector: string;
Expand Down

0 comments on commit c326abb

Please sign in to comment.