From b35e77ddefd1ea5a09b2e6748391b123ab476b55 Mon Sep 17 00:00:00 2001 From: Nikolaj Kappler Date: Tue, 6 Nov 2018 16:01:50 +0100 Subject: [PATCH] initial commit for tern addon typings. still WIP. workstream: --- types/codemirror/codemirror-tern.d.ts | 80 +++++++++++++++++++++++++++ types/codemirror/tsconfig.json | 1 + 2 files changed, 81 insertions(+) create mode 100644 types/codemirror/codemirror-tern.d.ts diff --git a/types/codemirror/codemirror-tern.d.ts b/types/codemirror/codemirror-tern.d.ts new file mode 100644 index 0000000000..5b882a096a --- /dev/null +++ b/types/codemirror/codemirror-tern.d.ts @@ -0,0 +1,80 @@ +//MUCH TODO + + +import * as CodeMirror from "codemirror"; + +declare module "codemiror" { + + export const TernServer: TernConstructor; + + interface TernServer { + + addDoc: ( + name: string, + doc: CodeMirror.Doc + ) => { + doc: CodeMirror.Doc, + name: string, + changed: { from: number, to: number } | null + }; + + delDoc: (id: string | CodeMirror.Editor | CodeMirror.Doc) => void; + + hideDoc: (id: string | CodeMirror.Editor | CodeMirror.Doc) => void; + + complete: (cm: CodeMirror.Editor) => void; + + showType: (cm: CodeMirror.Editor, pos?: CodeMirror.Position, callback?: Function) => void; + + showDocs: (cm: CodeMirror.Editor, pos?: CodeMirror.Position, callback?: Function) => void; + + updateArgHints: (cm: CodeMirror.Editor) => void; + + jumpToDef: (cm: CodeMirror.Editor) => void; + + jumpBack: (cm: CodeMirror.Editor) => void; + + rename: (cm: CodeMirror.Editor) => void; + + selectName: (cm: CodeMirror.Editor) => void; + + request: (cm: CodeMirror.Editor, query: string | Query, callback: (error: any, data?: any) => void, pos?: CodeMirror.Position) => void; + + destroy: () => void; + } + + interface TernConstructor { + new(options?: TernOptions): TernServer; + } + + interface TernOptions { + plugins?: any; + defs?: any[]; + getFile?: (name: string, callback: (doc: any) => void) => void; + fileFilter?: (value: any, docName: string, doc: any) => any; + switchToDoc?: (name: string, doc: any) => any; + showError?: (editor: CodeMirror.Editor, message: any) => void; + completionTip?: any; + typeTip?: any; + responseFilter?: (doc, query, request, error, data) => any; + useWorker?: boolean; + workerScript?: any; + workerDeps?: string[]; + } + + interface Query { + type: string; + file: string; //either the file name or a number in the following representation #0 #1 #2 etc... + scope?: Scope; + lineCharPositions?: boolean; + lineNumber?: number; + groupByFiles?: any; + start?: CodeMirror.Position; + end?: CodeMirror.Position; + } + +} + +declare module "codemirror/addon/tern/tern" { + export = CodeMirror; +} diff --git a/types/codemirror/tsconfig.json b/types/codemirror/tsconfig.json index 79d2eae5c3..caf680e2c2 100644 --- a/types/codemirror/tsconfig.json +++ b/types/codemirror/tsconfig.json @@ -23,6 +23,7 @@ "codemirror-panel.d.ts", "codemirror-runmode.d.ts", "codemirror-showhint.d.ts", + "codemirror-tern.d.ts", "searchcursor.d.ts", "test/index.ts", "test/matchbrackets.ts",