diff --git a/extensions/configuration-editing/src/extension.ts b/extensions/configuration-editing/src/extension.ts index 8643d5f643c3fc012f4144d12d8f654c029e814b..0503c0ba4cd19be5cabcbf42f0a2d9d825b4a94c 100644 --- a/extensions/configuration-editing/src/extension.ts +++ b/extensions/configuration-editing/src/extension.ts @@ -44,12 +44,22 @@ function registerKeybindingsCompletions(): vscode.Disposable { }); } -function updateLaunchJsonDecorations(editor: vscode.TextEditor) { +function newCompletionItem(text: string, range: vscode.Range) { + const item = new vscode.CompletionItem(JSON.stringify(text)); + item.kind = vscode.CompletionItemKind.Value; + item.textEdit = { + range, + newText: item.label + }; + return item; +} + +function updateLaunchJsonDecorations(editor: vscode.TextEditor | undefined) { if (!editor || path.basename(editor.document.fileName) !== 'launch.json') { return; } - const ranges = []; + const ranges: vscode.Range[] = []; let addPropertyAndValue = false; visit(editor.document.getText(), { onObjectProperty: (property, offset, length) => { @@ -68,13 +78,3 @@ function updateLaunchJsonDecorations(editor: vscode.TextEditor) { editor.setDecorations(decoration, ranges); } -function newCompletionItem(text: string, range: vscode.Range, documentation?: string) { - const item = new vscode.CompletionItem(JSON.stringify(text)); - item.kind = vscode.CompletionItemKind.Value; - item.documentation = documentation; - item.textEdit = { - range, - newText: item.label - }; - return item; -} diff --git a/extensions/configuration-editing/tsconfig.json b/extensions/configuration-editing/tsconfig.json index 8cb1633437728038691588a558cc8917c812ade2..4a9fdbed84519f3908ddb35e7b4a5efa966f8e6b 100644 --- a/extensions/configuration-editing/tsconfig.json +++ b/extensions/configuration-editing/tsconfig.json @@ -3,9 +3,10 @@ "noLib": true, "target": "es5", "module": "commonjs", - "outDir": "./out" + "outDir": "./out", + "strictNullChecks": true }, "exclude": [ "node_modules" ] -} \ No newline at end of file +} diff --git a/extensions/extension-editing/src/extension.ts b/extensions/extension-editing/src/extension.ts index a34c549ac12d6bf859e4021f33271862c49aa650..b7a4189554205fed67eb5bbe56a2da1835fbcaf2 100644 --- a/extensions/extension-editing/src/extension.ts +++ b/extensions/extension-editing/src/extension.ts @@ -83,7 +83,7 @@ namespace ast { let end = Number.MAX_VALUE; for (let name of dottedName.split('.')) { - let idx: number; + let idx: number = -1; while ((idx = identifiers.indexOf(name, idx + 1)) >= 0) { let myStart = spans[2 * idx]; let myEnd = spans[2 * idx + 1]; diff --git a/extensions/vscode-api-tests/src/utils.ts b/extensions/vscode-api-tests/src/utils.ts index 1cf42b7636e530dfe77761773a49aaeb763036c1..d22baa8d55a5caead61c69dd8bba745672b23492 100644 --- a/extensions/vscode-api-tests/src/utils.ts +++ b/extensions/vscode-api-tests/src/utils.ts @@ -62,7 +62,7 @@ export function cleanUp(): Thenable { } }); - vscode.commands.executeCommand('workbench.action.closeAllEditors').then(null, reject); + vscode.commands.executeCommand('workbench.action.closeAllEditors').then(undefined, reject); }).then(() => { assert.equal(vscode.window.visibleTextEditors.length, 0); @@ -76,4 +76,4 @@ export function cleanUp(): Thenable { // assert.equal(vscode.workspace.textDocuments.length, 0); }); -} \ No newline at end of file +} diff --git a/extensions/vscode-api-tests/src/window.test.ts b/extensions/vscode-api-tests/src/window.test.ts index b229fae155f61422daab606f1ef9a066fb25a824..065db16dc2671a46564cf797df1abbaa3d493cb6 100644 --- a/extensions/vscode-api-tests/src/window.test.ts +++ b/extensions/vscode-api-tests/src/window.test.ts @@ -19,7 +19,7 @@ suite('window namespace tests', () => { return window.showTextDocument(doc).then((editor) => { const active = window.activeTextEditor; assert.ok(active); - assert.ok(pathEquals(active.document.uri.fsPath, doc.uri.fsPath)); + assert.ok(pathEquals(active!.document.uri.fsPath, doc.uri.fsPath)); }); }); }); diff --git a/extensions/vscode-api-tests/src/workspace.test.ts b/extensions/vscode-api-tests/src/workspace.test.ts index 37c0f9e3f4f2e4d0589c8bda7cdf1d7b8eff93cd..b963ab62af558120649505686fb7227f0c15f4f9 100644 --- a/extensions/vscode-api-tests/src/workspace.test.ts +++ b/extensions/vscode-api-tests/src/workspace.test.ts @@ -6,7 +6,7 @@ 'use strict'; import * as assert from 'assert'; -import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit } from 'vscode'; +import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable } from 'vscode'; import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils'; import { join, basename } from 'path'; import * as fs from 'fs'; @@ -48,11 +48,13 @@ suite('workspace-namespace', () => { test('textDocuments', () => { assert.ok(Array.isArray(workspace.textDocuments)); - assert.throws(() => workspace.textDocuments = null); + assert.throws(() => (workspace).textDocuments = null); }); test('rootPath', () => { - assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace'))); + if (workspace.rootPath) { + assert.ok(pathEquals(workspace.rootPath, join(__dirname, '../testWorkspace'))); + } assert.throws(() => workspace.rootPath = 'farboo'); }); @@ -64,23 +66,22 @@ suite('workspace-namespace', () => { }); }); - test('openTextDocument, illegal path', done => { - workspace.openTextDocument('funkydonky.txt').then(doc => { - done(new Error('missing error')); + test('openTextDocument, illegal path', () => { + return workspace.openTextDocument('funkydonky.txt').then(doc => { + throw new Error('missing error'); }, err => { - done(); + // good! }); }); - test('openTextDocument, untitled is dirty', function (done) { + test('openTextDocument, untitled is dirty', function () { if (process.platform === 'win32') { - return done(); // TODO@Joh this test fails on windows + return; // TODO@Joh this test fails on windows } - workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath, './newfile.txt'))).then(doc => { + return workspace.openTextDocument(Uri.parse('untitled:' + join(workspace.rootPath, './newfile.txt'))).then(doc => { assert.equal(doc.uri.scheme, 'untitled'); assert.ok(doc.isDirty); - done(); }); }); @@ -137,7 +138,7 @@ suite('workspace-namespace', () => { test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => { return createRandomFile().then(file => { - let disposables = []; + let disposables: Disposable[] = []; let onDidOpenTextDocument = false; disposables.push(workspace.onDidOpenTextDocument(e => { @@ -370,7 +371,7 @@ suite('workspace-namespace', () => { }); test('findFiles', () => { - return workspace.findFiles('*.js', null).then((res) => { + return workspace.findFiles('*.js').then((res) => { assert.equal(res.length, 1); assert.equal(basename(workspace.asRelativePath(res[0])), 'far.js'); }); diff --git a/extensions/vscode-api-tests/tsconfig.json b/extensions/vscode-api-tests/tsconfig.json index 44066990ddcba8d19d3c121b9c1798734e9b5150..e6fc5096aef213addc4a1c2b6b56903b917b5ac2 100644 --- a/extensions/vscode-api-tests/tsconfig.json +++ b/extensions/vscode-api-tests/tsconfig.json @@ -4,9 +4,10 @@ "target": "ES5", "outDir": "out", "noLib": true, - "sourceMap": true + "sourceMap": true, + "strictNullChecks": true }, "exclude": [ "node_modules" ] -} \ No newline at end of file +} diff --git a/extensions/vscode-api-tests/typings/mocha.d.ts b/extensions/vscode-api-tests/typings/mocha.d.ts index f677473dcdd76f32f6bcf36d2754b8d144578c1d..1a66189a454a86d12a2ee618f6858afcf3b0e3a8 100644 --- a/extensions/vscode-api-tests/typings/mocha.d.ts +++ b/extensions/vscode-api-tests/typings/mocha.d.ts @@ -6,7 +6,8 @@ declare function run(): void; declare function suite(name: string, fn: (err?) => void); -declare function test(name: string, fn: (done?: (err?) => void) => void); +declare function test(name: string, fn: () => void); +declare function test(name: string, fn: (done: (err?) => void) => void); declare function suiteSetup(fn: (done?: (err?) => void) => void); declare function suiteTeardown(fn: (done?: (err?) => void) => void); declare function setup(fn: (done?: (err?) => void) => void); diff --git a/src/typings/mocha.d.ts b/src/typings/mocha.d.ts index f677473dcdd76f32f6bcf36d2754b8d144578c1d..1a66189a454a86d12a2ee618f6858afcf3b0e3a8 100644 --- a/src/typings/mocha.d.ts +++ b/src/typings/mocha.d.ts @@ -6,7 +6,8 @@ declare function run(): void; declare function suite(name: string, fn: (err?) => void); -declare function test(name: string, fn: (done?: (err?) => void) => void); +declare function test(name: string, fn: () => void); +declare function test(name: string, fn: (done: (err?) => void) => void); declare function suiteSetup(fn: (done?: (err?) => void) => void); declare function suiteTeardown(fn: (done?: (err?) => void) => void); declare function setup(fn: (done?: (err?) => void) => void);