mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-13 12:37:16 +08:00
Merge pull request #17275 from madbrain/master
[codemirror] Linter function can either be sync or async
This commit is contained in:
13
types/codemirror/index.d.ts
vendored
13
types/codemirror/index.d.ts
vendored
@@ -1097,7 +1097,7 @@ declare namespace CodeMirror {
|
||||
* Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless
|
||||
* the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined.
|
||||
*/
|
||||
function overlayMode<T, S>(base: Mode<T>, overlay: Mode<S>, combine?: boolean): Mode<any>
|
||||
function overlayMode<T, S>(base: Mode<T>, overlay: Mode<S>, combine?: boolean): Mode<any>;
|
||||
|
||||
/**
|
||||
* async specifies that the lint process runs asynchronously. hasGutters specifies that lint errors should be displayed in the CodeMirror
|
||||
@@ -1114,13 +1114,20 @@ declare namespace CodeMirror {
|
||||
* linter.
|
||||
*/
|
||||
interface LintOptions extends LintStateOptions {
|
||||
getAnnotations: AnnotationsCallback;
|
||||
getAnnotations: Linter | AsyncLinter;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that return errors found during the linting process.
|
||||
*/
|
||||
interface Linter {
|
||||
(content: string, options: LintStateOptions, codeMirror: Editor): Annotation[] | PromiseLike<Annotation[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that calls the updateLintingCallback with any errors found during the linting process.
|
||||
*/
|
||||
interface AnnotationsCallback {
|
||||
interface AsyncLinter {
|
||||
(content: string, updateLintingCallback: UpdateLintingCallback, options: LintStateOptions, codeMirror: Editor): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ var lintStateOptions: CodeMirror.LintStateOptions = {
|
||||
hasGutters: true
|
||||
};
|
||||
|
||||
var lintOptions: CodeMirror.LintOptions = {
|
||||
var asyncLintOptions: CodeMirror.LintOptions = {
|
||||
async: true,
|
||||
hasGutters: true,
|
||||
getAnnotations: (content: string,
|
||||
@@ -37,6 +37,14 @@ var lintOptions: CodeMirror.LintOptions = {
|
||||
codeMirror: CodeMirror.Editor) => {}
|
||||
};
|
||||
|
||||
var syncLintOptions: CodeMirror.LintOptions = {
|
||||
async: false,
|
||||
hasGutters: true,
|
||||
getAnnotations: (content: string,
|
||||
options: CodeMirror.LintStateOptions,
|
||||
codeMirror: CodeMirror.Editor): CodeMirror.Annotation[] => { return []; }
|
||||
};
|
||||
|
||||
var updateLintingCallback: CodeMirror.UpdateLintingCallback = (codeMirror: CodeMirror.Editor,
|
||||
annotations: CodeMirror.Annotation[]) => {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user