Skip to content

Commit

Permalink
build: fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed May 1, 2020
1 parent 68b8085 commit 53ce46b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"group": "build",
"problemMatcher": ["$tsc-watch"],
"label": "npm: watch",
"detail": "tsc -p . -w",
"runOptions": {
"runOn": "folderOpen",
},
},
],
}
7 changes: 3 additions & 4 deletions src/codeEditor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { BehaviorSubject } from 'rxjs'
import * as sinon from 'sinon'
import * as sourcegraph from 'sourcegraph'
import { assertTypeIsCompatible } from './util'
import { subTypeOf } from './util'

export const createStubCodeEditor = ({
document,
selections = [],
}: Pick<sourcegraph.CodeEditor, 'document'> & Partial<Pick<sourcegraph.CodeEditor, 'selections'>>) => {
const codeEditor = {
const codeEditor = subTypeOf<sourcegraph.CodeEditor>()({
type: 'CodeEditor' as const,
document,
get selections(): sourcegraph.Selection[] {
Expand All @@ -23,7 +23,6 @@ export const createStubCodeEditor = ({
decorations: sourcegraph.TextDocumentDecoration[]
): void => undefined
),
}
assertTypeIsCompatible<sourcegraph.CodeEditor>(codeEditor)
})
return codeEditor
}
7 changes: 3 additions & 4 deletions src/textDocument.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as sinon from 'sinon'
import * as sourcegraph from 'sourcegraph'
import { assertTypeIsCompatible, notImplemented } from './util'
import { notImplemented, subTypeOf } from './util'

/**
* Creates a stub TextDocument.
*
*/
export const createStubTextDocument = (init: Pick<sourcegraph.TextDocument, 'languageId' | 'text' | 'uri'>) => {
const textDocument = {
const textDocument = subTypeOf<sourcegraph.TextDocument>()({
...init,
// TODO share the implementation of these methods with the real implementations
getWordRangeAtPosition: sinon.spy<(position: sourcegraph.Position) => sourcegraph.Range | undefined>(
Expand All @@ -17,7 +17,6 @@ export const createStubTextDocument = (init: Pick<sourcegraph.TextDocument, 'lan
offsetAt: sinon.spy<(position: sourcegraph.Position) => number>(notImplemented),
positionAt: sinon.spy<(offset: number) => sourcegraph.Position>(notImplemented),
validateRange: sinon.spy<(range: sourcegraph.Range) => sourcegraph.Range>(notImplemented),
}
assertTypeIsCompatible<sourcegraph.TextDocument>(textDocument)
})
return textDocument
}

0 comments on commit 53ce46b

Please sign in to comment.