diff --git a/types/codemirror/codemirror-showhint.d.ts b/types/codemirror/codemirror-showhint.d.ts index 55a3d6012b..c6f367d0d2 100644 --- a/types/codemirror/codemirror-showhint.d.ts +++ b/types/codemirror/codemirror-showhint.d.ts @@ -1,6 +1,8 @@ // Type definitions for CodeMirror // Project: https://github.com/marijnh/CodeMirror -// Definitions by: jacqt , basarat +// Definitions by: jacqt +// basarat +// mbilsing // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // See docs https://codemirror.net/doc/manual.html#addon_show-hint @@ -16,7 +18,7 @@ declare module "codemirror" { and return a {list, from, to} object, where list is an array of strings or objects (the completions), and from and to give the start and end of the token that is being completed as {line, ch} objects. An optional selectedHint property (an integer) can be added to the completion object to control the initially selected hint. */ - function showHint(cm: CodeMirror.Doc, hinter?: HintFunction, options?: ShowHintOptions): void; + function showHint(cm: CodeMirror.Editor, hinter?: HintFunction, options?: ShowHintOptions): void; interface Hints { from: Position; @@ -32,7 +34,7 @@ declare module "codemirror" { displayText?: string; from?: Position; /** Called if a completion is picked. If provided *you* are responsible for applying the completion */ - hint?: (cm: any, data: Hints, cur: Hint) => void; + hint?: (cm: CodeMirror.Editor, data: Hints, cur: Hint) => void; render?: (element: HTMLLIElement, data: Hints, cur: Hint) => void; to?: Position; } @@ -41,18 +43,15 @@ declare module "codemirror" { /** An extension of the existing CodeMirror typings for the Editor.on("keyup", func) syntax */ on(eventName: string, handler: (doc: CodeMirror.Doc, event: any) => void): void; off(eventName: string, handler: (doc: CodeMirror.Doc, event: any) => void): void; - } - - interface Doc { showHint: (options: ShowHintOptions) => void; } interface HintFunction { - (doc: CodeMirror.Doc): Hints; + (cm: CodeMirror.Editor): Hints; } interface AsyncHintFunction { - (doc: CodeMirror.Doc, callback: (hints: Hints) => any): any; + (cm: CodeMirror.Editor, callback: (hints: Hints) => any): any; async?: boolean; } diff --git a/types/codemirror/test/showhint.ts b/types/codemirror/test/showhint.ts index 00dbe6bed4..0aabcc9a86 100644 --- a/types/codemirror/test/showhint.ts +++ b/types/codemirror/test/showhint.ts @@ -1,16 +1,16 @@ -var doc = new CodeMirror.Doc('text'); +var cm = CodeMirror(document.body, {value: 'text'}); var pos = new CodeMirror.Pos(2, 3); -CodeMirror.showHint(doc); -CodeMirror.showHint(doc, function (cm) { +CodeMirror.showHint(cm); +CodeMirror.showHint(cm, function (cm) { return { from: pos, list: ["one", "two"], to: pos }; }); -CodeMirror.showHint(doc, function (cm) { +CodeMirror.showHint(cm, function (cm) { return { from: pos, list: [ @@ -32,7 +32,7 @@ CodeMirror.showHint(doc, function (cm) { }; }); var asyncHintFunc : CodeMirror.AsyncHintFunction = - (doc: CodeMirror.Doc, callback: (hints: CodeMirror.Hints) => any) => { + (cm: CodeMirror.Editor, callback: (hints: CodeMirror.Hints) => any) => { callback({ from: pos, list: ["one", "two"], @@ -41,7 +41,7 @@ var asyncHintFunc : CodeMirror.AsyncHintFunction = }; asyncHintFunc.async = true; -doc.showHint({ +cm.showHint({ completeSingle: false, hint: asyncHintFunc })