diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 2c6cac34ad609..6d4d7bf2f147e 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -806,7 +806,79 @@ "./vs/workbench/test/common/editor/editorOptions.test.ts", "./vs/workbench/test/common/notifications.test.ts", "./vs/workbench/test/electron-browser/api/extHostTypes.test.ts", - "./vs/workbench/test/electron-browser/api/mock.ts" + "./vs/workbench/test/electron-browser/api/mock.ts", + "./vs/base/parts/quickopen/test/browser/quickopen.test.ts", + "./vs/base/parts/tree/test/browser/treeModel.test.ts", + "./vs/base/parts/tree/test/browser/treeViewModel.test.ts", + "./vs/editor/contrib/documentSymbols/test/outlineModel.test.ts", + "./vs/editor/contrib/snippet/test/snippetController2.old.test.ts", + "./vs/editor/contrib/snippet/test/snippetController2.test.ts", + "./vs/editor/contrib/suggest/test/suggestMemory.test.ts", + "./vs/editor/contrib/suggest/test/suggestModel.test.ts", + "./vs/editor/standalone/test/browser/standaloneLanguages.test.ts", + "./vs/platform/commands/test/commands.test.ts", + "./vs/platform/extensionManagement/test/electron-browser/extensionEnablementService.test.ts", + "./vs/platform/keybinding/test/common/abstractKeybindingService.test.ts", + "./vs/platform/storage/test/node/storageService.test.ts", + "./vs/platform/telemetry/test/electron-browser/commonProperties.test.ts", + "./vs/platform/theme/test/electron-browser/colorRegistry.releaseTest.ts", + "./vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts", + "./vs/workbench/parts/debug/test/browser/debugANSIHandling.test.ts", + "./vs/workbench/parts/debug/test/node/debugger.test.ts", + "./vs/workbench/parts/experiments/test/electron-browser/experimentService.test.ts", + "./vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts", + "./vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts", + "./vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts", + "./vs/workbench/parts/extensions/test/electron-browser/extensionsWorkbenchService.test.ts", + "./vs/workbench/parts/files/test/electron-browser/explorerModel.test.ts", + "./vs/workbench/parts/search/test/browser/openFileHandler.test.ts", + "./vs/workbench/parts/search/test/browser/searchViewlet.test.ts", + "./vs/workbench/parts/search/test/common/queryBuilder.test.ts", + "./vs/workbench/parts/search/test/common/searchModel.test.ts", + "./vs/workbench/parts/search/test/common/searchResult.test.ts", + "./vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts", + "./vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts", + "./vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts", + "./vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts", + "./vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts", + "./vs/workbench/services/files/test/electron-browser/fileService.test.ts", + "./vs/workbench/services/group/test/browser/editorGroupsService.test.ts", + "./vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts", + "./vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts", + "./vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts", + "./vs/workbench/services/preferences/test/common/preferencesModel.test.ts", + "./vs/workbench/services/progress/test/progressService.test.ts", + "./vs/workbench/services/search/test/node/rawSearchService.test.ts", + "./vs/workbench/services/search/test/node/search.test.ts", + "./vs/workbench/services/search/test/node/textSearch.integrationTest.ts", + "./vs/workbench/services/textfile/test/textFileService.test.ts", + "./vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts", + "./vs/workbench/test/browser/part.test.ts", + "./vs/workbench/test/browser/parts/editor/baseEditor.test.ts", + "./vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts", + "./vs/workbench/test/browser/quickopen.test.ts", + "./vs/workbench/test/browser/viewlet.test.ts", + "./vs/workbench/test/common/editor/editorDiffModel.test.ts", + "./vs/workbench/test/common/editor/editorGroups.test.ts", + "./vs/workbench/test/common/editor/editorModel.test.ts", + "./vs/workbench/test/common/editor/resourceEditorInput.test.ts", + "./vs/workbench/test/common/editor/untitledEditor.test.ts", + "./vs/workbench/test/common/memento.test.ts", + "./vs/workbench/test/electron-browser/api/extHostCommands.test.ts", + "./vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts", + "./vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts", + "./vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts", + "./vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts", + "./vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts", + "./vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts", + "./vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts", + "./vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts", + "./vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts", + "./vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts", + "./vs/workbench/test/electron-browser/api/mainThreadCommands.test.ts", + "./vs/workbench/test/electron-browser/api/mainThreadDiagnostics.test.ts", + "./vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts", + "./vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts" ], "exclude": [ "./typings/require-monaco.d.ts" diff --git a/src/vs/base/parts/quickopen/test/browser/quickopen.test.ts b/src/vs/base/parts/quickopen/test/browser/quickopen.test.ts index f42a2f73e9bc5..f53d0b4e1edc5 100644 --- a/src/vs/base/parts/quickopen/test/browser/quickopen.test.ts +++ b/src/vs/base/parts/quickopen/test/browser/quickopen.test.ts @@ -38,11 +38,11 @@ suite('QuickOpen', () => { model.addEntries([entry1, entry2, entry3]); const ds = new DataSource(model); - assert.equal(entry1.getId(), ds.getId(null, entry1)); - assert.equal(true, ds.hasChildren(null, model)); - assert.equal(false, ds.hasChildren(null, entry1)); + assert.equal(entry1.getId(), ds.getId(null!, entry1)); + assert.equal(true, ds.hasChildren(null!, model)); + assert.equal(false, ds.hasChildren(null!, entry1)); - ds.getChildren(null, model).then((children: any[]) => { + ds.getChildren(null!, model).then((children: any[]) => { assert.equal(3, children.length); }); }); diff --git a/src/vs/base/parts/tree/test/browser/treeModel.test.ts b/src/vs/base/parts/tree/test/browser/treeModel.test.ts index baa5350b49da0..7e034192aba7f 100644 --- a/src/vs/base/parts/tree/test/browser/treeModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeModel.test.ts @@ -36,7 +36,7 @@ export class FakeRenderer { class TreeContext implements _.ITreeContext { - public tree: _.ITree = null; + public tree: _.ITree = null!; public options: _.ITreeOptions = { autoExpandSingleChildren: true }; public dataSource: _.IDataSource; public renderer: _.IRenderer; diff --git a/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts b/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts index 0f0a1f81644e3..da11e8cfba3bb 100644 --- a/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts @@ -17,7 +17,7 @@ function makeItem(id, height): any { } function makeItems(...args: any[]) { - var r = []; + var r: any[] = []; for (var i = 0; i < args.length; i += 2) { r.push(makeItem(args[i], args[i + 1])); @@ -59,7 +59,7 @@ suite('TreeView - HeightMap', () => { teardown(() => { rangeMap.dispose(); - rangeMap = null; + rangeMap = null!; }); test('simple', () => { diff --git a/src/vs/editor/contrib/documentSymbols/test/outlineModel.test.ts b/src/vs/editor/contrib/documentSymbols/test/outlineModel.test.ts index b8543a7806292..057bdfbea2c33 100644 --- a/src/vs/editor/contrib/documentSymbols/test/outlineModel.test.ts +++ b/src/vs/editor/contrib/documentSymbols/test/outlineModel.test.ts @@ -82,16 +82,16 @@ suite('OutlineModel', function () { } function fakeMarker(range: Range): IMarker { - return { ...range, owner: 'ffff', message: 'test', severity: MarkerSeverity.Error, resource: null }; + return { ...range, owner: 'ffff', message: 'test', severity: MarkerSeverity.Error, resource: null! }; } test('OutlineElement - updateMarker', function () { - let e0 = new OutlineElement('foo1', null, fakeSymbolInformation(new Range(1, 1, 1, 10))); - let e1 = new OutlineElement('foo2', null, fakeSymbolInformation(new Range(2, 1, 5, 1))); - let e2 = new OutlineElement('foo3', null, fakeSymbolInformation(new Range(6, 1, 10, 10))); + let e0 = new OutlineElement('foo1', null!, fakeSymbolInformation(new Range(1, 1, 1, 10))); + let e1 = new OutlineElement('foo2', null!, fakeSymbolInformation(new Range(2, 1, 5, 1))); + let e2 = new OutlineElement('foo3', null!, fakeSymbolInformation(new Range(6, 1, 10, 10))); - let group = new OutlineGroup('group', null, null, 1); + let group = new OutlineGroup('group', null!, null!, 1); group.children[e0.id] = e0; group.children[e1.id] = e1; group.children[e2.id] = e2; @@ -113,11 +113,11 @@ suite('OutlineModel', function () { test('OutlineElement - updateMarker, 2', function () { - let p = new OutlineElement('A', null, fakeSymbolInformation(new Range(1, 1, 11, 1))); - let c1 = new OutlineElement('A/B', null, fakeSymbolInformation(new Range(2, 4, 5, 4))); - let c2 = new OutlineElement('A/C', null, fakeSymbolInformation(new Range(6, 4, 9, 4))); + let p = new OutlineElement('A', null!, fakeSymbolInformation(new Range(1, 1, 11, 1))); + let c1 = new OutlineElement('A/B', null!, fakeSymbolInformation(new Range(2, 4, 5, 4))); + let c2 = new OutlineElement('A/C', null!, fakeSymbolInformation(new Range(6, 4, 9, 4))); - let group = new OutlineGroup('group', null, null, 1); + let group = new OutlineGroup('group', null!, null!, 1); group.children[p.id] = p; p.children[c1.id] = c1; p.children[c2.id] = c2; @@ -155,16 +155,16 @@ suite('OutlineModel', function () { let model = new class extends OutlineModel { constructor() { - super(null); + super(null!); } readyForTesting() { this._groups = this.children as any; } }; - model.children['g1'] = new OutlineGroup('g1', model, null, 1); + model.children['g1'] = new OutlineGroup('g1', model, null!, 1); model.children['g1'].children['c1'] = new OutlineElement('c1', model.children['g1'], fakeSymbolInformation(new Range(1, 1, 11, 1))); - model.children['g2'] = new OutlineGroup('g2', model, null, 1); + model.children['g2'] = new OutlineGroup('g2', model, null!, 1); model.children['g2'].children['c2'] = new OutlineElement('c2', model.children['g2'], fakeSymbolInformation(new Range(1, 1, 7, 1))); model.children['g2'].children['c2'].children['c2.1'] = new OutlineElement('c2.1', model.children['g2'].children['c2'], fakeSymbolInformation(new Range(1, 3, 2, 19))); model.children['g2'].children['c2'].children['c2.2'] = new OutlineElement('c2.2', model.children['g2'].children['c2'], fakeSymbolInformation(new Range(4, 1, 6, 10))); diff --git a/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts b/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts index 4460011c007c6..9770cb3642078 100644 --- a/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts +++ b/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts @@ -22,7 +22,7 @@ class TestSnippetController extends SnippetController2 { } isInSnippetMode(): boolean { - return SnippetController2.InSnippetMode.getValue(this._contextKeyService); + return SnippetController2.InSnippetMode.getValue(this._contextKeyService)!; } } @@ -42,7 +42,7 @@ suite('SnippetController', () => { } withTestCodeEditor(lines, {}, (editor, cursor) => { - editor.getModel().updateOptions({ + editor.getModel()!.updateOptions({ insertSpaces: false }); let snippetController = editor.registerAndInstantiateContribution(TestSnippetController); @@ -63,30 +63,30 @@ suite('SnippetController', () => { editor.setPosition({ lineNumber: 4, column: 2 }); snippetController.insert(template, 0, 0); - assert.equal(editor.getModel().getLineContent(4), '\tfor (var index; index < array.length; index++) {'); - assert.equal(editor.getModel().getLineContent(5), '\t\tvar element = array[index];'); - assert.equal(editor.getModel().getLineContent(6), '\t\t'); - assert.equal(editor.getModel().getLineContent(7), '\t}'); + assert.equal(editor.getModel()!.getLineContent(4), '\tfor (var index; index < array.length; index++) {'); + assert.equal(editor.getModel()!.getLineContent(5), '\t\tvar element = array[index];'); + assert.equal(editor.getModel()!.getLineContent(6), '\t\t'); + assert.equal(editor.getModel()!.getLineContent(7), '\t}'); editor.trigger('test', 'type', { text: 'i' }); - assert.equal(editor.getModel().getLineContent(4), '\tfor (var i; i < array.length; i++) {'); - assert.equal(editor.getModel().getLineContent(5), '\t\tvar element = array[i];'); - assert.equal(editor.getModel().getLineContent(6), '\t\t'); - assert.equal(editor.getModel().getLineContent(7), '\t}'); + assert.equal(editor.getModel()!.getLineContent(4), '\tfor (var i; i < array.length; i++) {'); + assert.equal(editor.getModel()!.getLineContent(5), '\t\tvar element = array[i];'); + assert.equal(editor.getModel()!.getLineContent(6), '\t\t'); + assert.equal(editor.getModel()!.getLineContent(7), '\t}'); snippetController.next(); editor.trigger('test', 'type', { text: 'arr' }); - assert.equal(editor.getModel().getLineContent(4), '\tfor (var i; i < arr.length; i++) {'); - assert.equal(editor.getModel().getLineContent(5), '\t\tvar element = arr[i];'); - assert.equal(editor.getModel().getLineContent(6), '\t\t'); - assert.equal(editor.getModel().getLineContent(7), '\t}'); + assert.equal(editor.getModel()!.getLineContent(4), '\tfor (var i; i < arr.length; i++) {'); + assert.equal(editor.getModel()!.getLineContent(5), '\t\tvar element = arr[i];'); + assert.equal(editor.getModel()!.getLineContent(6), '\t\t'); + assert.equal(editor.getModel()!.getLineContent(7), '\t}'); snippetController.prev(); editor.trigger('test', 'type', { text: 'j' }); - assert.equal(editor.getModel().getLineContent(4), '\tfor (var j; j < arr.length; j++) {'); - assert.equal(editor.getModel().getLineContent(5), '\t\tvar element = arr[j];'); - assert.equal(editor.getModel().getLineContent(6), '\t\t'); - assert.equal(editor.getModel().getLineContent(7), '\t}'); + assert.equal(editor.getModel()!.getLineContent(4), '\tfor (var j; j < arr.length; j++) {'); + assert.equal(editor.getModel()!.getLineContent(5), '\t\tvar element = arr[j];'); + assert.equal(editor.getModel()!.getLineContent(6), '\t\t'); + assert.equal(editor.getModel()!.getLineContent(7), '\t}'); snippetController.next(); snippetController.next(); @@ -99,10 +99,10 @@ suite('SnippetController', () => { editor.setPosition({ lineNumber: 4, column: 2 }); snippetController.insert(template, 0, 0); - assert.equal(editor.getModel().getLineContent(4), '\tfor (var index; index < array.length; index++) {'); - assert.equal(editor.getModel().getLineContent(5), '\t\tvar element = array[index];'); - assert.equal(editor.getModel().getLineContent(6), '\t\t'); - assert.equal(editor.getModel().getLineContent(7), '\t}'); + assert.equal(editor.getModel()!.getLineContent(4), '\tfor (var index; index < array.length; index++) {'); + assert.equal(editor.getModel()!.getLineContent(5), '\t\tvar element = array[index];'); + assert.equal(editor.getModel()!.getLineContent(6), '\t\t'); + assert.equal(editor.getModel()!.getLineContent(7), '\t}'); snippetController.cancel(); assert.deepEqual(editor.getPosition(), new Position(4, 16)); @@ -114,7 +114,7 @@ suite('SnippetController', () => { // editor.setPosition({ lineNumber: 4, column: 2 }); // snippetController.insert(codeSnippet, 0, 0); - // editor.getModel().applyEdits([{ + // editor.getModel()!.applyEdits([{ // forceMoveMarkers: false, // identifier: null, // isAutoWhitespaceEdit: false, @@ -131,7 +131,7 @@ suite('SnippetController', () => { // editor.setPosition({ lineNumber: 4, column: 2 }); // snippetController.run(codeSnippet, 0, 0); - // editor.getModel().applyEdits([{ + // editor.getModel()!.applyEdits([{ // forceMoveMarkers: false, // identifier: null, // isAutoWhitespaceEdit: false, @@ -148,7 +148,7 @@ suite('SnippetController', () => { // editor.setPosition({ lineNumber: 4, column: 2 }); // snippetController.run(codeSnippet, 0, 0); - // editor.getModel().applyEdits([{ + // editor.getModel()!.applyEdits([{ // forceMoveMarkers: false, // identifier: null, // isAutoWhitespaceEdit: false, @@ -165,7 +165,7 @@ suite('SnippetController', () => { // editor.setPosition({ lineNumber: 4, column: 2 }); // snippetController.run(codeSnippet, 0, 0); - // editor.getModel().applyEdits([{ + // editor.getModel()!.applyEdits([{ // forceMoveMarkers: false, // identifier: null, // isAutoWhitespaceEdit: false, @@ -182,7 +182,7 @@ suite('SnippetController', () => { editor.setPosition({ lineNumber: 4, column: 2 }); snippetController.insert(codeSnippet, 0, 0); - editor.getModel().setValue('goodbye'); + editor.getModel()!.setValue('goodbye'); assert.equal(snippetController.isInSnippetMode(), false); }); @@ -193,7 +193,7 @@ suite('SnippetController', () => { editor.setPosition({ lineNumber: 4, column: 2 }); snippetController.insert(codeSnippet, 0, 0); - editor.getModel().undo(); + editor.getModel()!.undo(); assert.equal(snippetController.isInSnippetMode(), false); }); @@ -242,8 +242,8 @@ suite('SnippetController', () => { codeSnippet = 'foo$0'; snippetController.insert(codeSnippet, 0, 0); - assert.equal(editor.getSelections().length, 2); - const [first, second] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 2); + const [first, second] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 1, startColumn: 4, endLineNumber: 1, endColumn: 4 }), first.toString()); assert.ok(second.equalsRange({ startLineNumber: 2, startColumn: 4, endLineNumber: 2, endColumn: 4 }), second.toString()); }); @@ -257,8 +257,8 @@ suite('SnippetController', () => { codeSnippet = 'foo$0bar'; snippetController.insert(codeSnippet, 0, 0); - assert.equal(editor.getSelections().length, 2); - const [first, second] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 2); + const [first, second] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 1, startColumn: 4, endLineNumber: 1, endColumn: 4 }), first.toString()); assert.ok(second.equalsRange({ startLineNumber: 2, startColumn: 4, endLineNumber: 2, endColumn: 4 }), second.toString()); }); @@ -272,8 +272,8 @@ suite('SnippetController', () => { codeSnippet = 'foo$0bar'; snippetController.insert(codeSnippet, 0, 0); - assert.equal(editor.getSelections().length, 2); - const [first, second] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 2); + const [first, second] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 1, startColumn: 4, endLineNumber: 1, endColumn: 4 }), first.toString()); assert.ok(second.equalsRange({ startLineNumber: 1, startColumn: 14, endLineNumber: 1, endColumn: 14 }), second.toString()); }); @@ -287,8 +287,8 @@ suite('SnippetController', () => { codeSnippet = 'foo\n$0\nbar'; snippetController.insert(codeSnippet, 0, 0); - assert.equal(editor.getSelections().length, 2); - const [first, second] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 2); + const [first, second] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 }), first.toString()); assert.ok(second.equalsRange({ startLineNumber: 4, startColumn: 1, endLineNumber: 4, endColumn: 1 }), second.toString()); }); @@ -302,8 +302,8 @@ suite('SnippetController', () => { codeSnippet = 'foo\n$0\nbar'; snippetController.insert(codeSnippet, 0, 0); - assert.equal(editor.getSelections().length, 2); - const [first, second] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 2); + const [first, second] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 }), first.toString()); assert.ok(second.equalsRange({ startLineNumber: 4, startColumn: 1, endLineNumber: 4, endColumn: 1 }), second.toString()); }); @@ -316,8 +316,8 @@ suite('SnippetController', () => { codeSnippet = 'xo$0r'; snippetController.insert(codeSnippet, 1, 0); - assert.equal(editor.getSelections().length, 1); - assert.ok(editor.getSelection().equalsRange({ startLineNumber: 2, startColumn: 8, endColumn: 8, endLineNumber: 2 })); + assert.equal(editor.getSelections()!.length, 1); + assert.ok(editor.getSelection()!.equalsRange({ startLineNumber: 2, startColumn: 8, endColumn: 8, endLineNumber: 2 })); }); }); @@ -329,9 +329,9 @@ suite('SnippetController', () => { codeSnippet = '{{% url_**$1** %}}'; controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getSelections().length, 1); - assert.ok(editor.getSelection().equalsRange({ startLineNumber: 1, startColumn: 27, endLineNumber: 1, endColumn: 27 })); - assert.equal(editor.getModel().getValue(), 'example example {{% url_**** %}}'); + assert.equal(editor.getSelections()!.length, 1); + assert.ok(editor.getSelection()!.equalsRange({ startLineNumber: 1, startColumn: 27, endLineNumber: 1, endColumn: 27 })); + assert.equal(editor.getModel()!.getValue(), 'example example {{% url_**** %}}'); }, ['example example sc']); @@ -347,9 +347,9 @@ suite('SnippetController', () => { controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getSelections().length, 1); - assert.ok(editor.getSelection().equalsRange({ startLineNumber: 2, startColumn: 2, endLineNumber: 2, endColumn: 2 }), editor.getSelection().toString()); - assert.equal(editor.getModel().getValue(), 'afterEach((done) => {\n\ttest\n});'); + assert.equal(editor.getSelections()!.length, 1); + assert.ok(editor.getSelection()!.equalsRange({ startLineNumber: 2, startColumn: 2, endLineNumber: 2, endColumn: 2 }), editor.getSelection()!.toString()); + assert.equal(editor.getModel()!.getValue(), 'afterEach((done) => {\n\ttest\n});'); }, ['af']); @@ -365,9 +365,9 @@ suite('SnippetController', () => { controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getSelections().length, 1); - assert.ok(editor.getSelection().equalsRange({ startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 }), editor.getSelection().toString()); - assert.equal(editor.getModel().getValue(), 'afterEach((done) => {\n\ttest\n});'); + assert.equal(editor.getSelections()!.length, 1); + assert.ok(editor.getSelection()!.equalsRange({ startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 }), editor.getSelection()!.toString()); + assert.equal(editor.getModel()!.getValue(), 'afterEach((done) => {\n\ttest\n});'); }, ['af']); @@ -381,9 +381,9 @@ suite('SnippetController', () => { controller.insert(codeSnippet, 8, 0); - assert.equal(editor.getModel().getValue(), 'after'); - assert.equal(editor.getSelections().length, 1); - assert.ok(editor.getSelection().equalsRange({ startLineNumber: 1, startColumn: 4, endLineNumber: 1, endColumn: 4 }), editor.getSelection().toString()); + assert.equal(editor.getModel()!.getValue(), 'after'); + assert.equal(editor.getSelections()!.length, 1); + assert.ok(editor.getSelection()!.equalsRange({ startLineNumber: 1, startColumn: 4, endLineNumber: 1, endColumn: 4 }), editor.getSelection()!.toString()); }, ['afterone']); }); @@ -405,8 +405,8 @@ suite('SnippetController', () => { controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getSelections().length, 2); - const [first, second] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 2); + const [first, second] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 5, startColumn: 3, endLineNumber: 5, endColumn: 3 }), first.toString()); assert.ok(second.equalsRange({ startLineNumber: 2, startColumn: 2, endLineNumber: 2, endColumn: 2 }), second.toString()); @@ -430,8 +430,8 @@ suite('SnippetController', () => { controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getSelections().length, 1); - const [first] = editor.getSelections(); + assert.equal(editor.getSelections()!.length, 1); + const [first] = editor.getSelections()!; assert.ok(first.equalsRange({ startLineNumber: 2, startColumn: 3, endLineNumber: 2, endColumn: 3 }), first.toString()); @@ -450,7 +450,7 @@ suite('SnippetController', () => { controller.insert(codeSnippet, 2, 0); - assert.ok(editor.getSelection().equalsRange({ startLineNumber: 1, startColumn: 10, endLineNumber: 1, endColumn: 10 })); + assert.ok(editor.getSelection()!.equalsRange({ startLineNumber: 1, startColumn: 10, endLineNumber: 1, endColumn: 10 })); }, ['af', '\taf']); }); @@ -466,7 +466,7 @@ suite('SnippetController', () => { codeSnippet = '_foo'; controller.insert(codeSnippet, 1, 0); - assert.equal(editor.getModel().getValue(), 'this._foo\nabc_foo'); + assert.equal(editor.getModel()!.getValue(), 'this._foo\nabc_foo'); }, ['this._', 'abc']); @@ -479,7 +479,7 @@ suite('SnippetController', () => { codeSnippet = 'XX'; controller.insert(codeSnippet, 1, 0); - assert.equal(editor.getModel().getValue(), 'this.XX\nabcXX'); + assert.equal(editor.getModel()!.getValue(), 'this.XX\nabcXX'); }, ['this._', 'abc']); @@ -493,7 +493,7 @@ suite('SnippetController', () => { codeSnippet = '_foo'; controller.insert(codeSnippet, 1, 0); - assert.equal(editor.getModel().getValue(), 'this._foo\nabc_foo\ndef_foo'); + assert.equal(editor.getModel()!.getValue(), 'this._foo\nabc_foo\ndef_foo'); }, ['this._', 'abc', 'def_']); @@ -507,7 +507,7 @@ suite('SnippetController', () => { codeSnippet = '._foo'; controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getModel().getValue(), 'this._foo\nabc._foo\ndef._foo'); + assert.equal(editor.getModel()!.getValue(), 'this._foo\nabc._foo\ndef._foo'); }, ['this._', 'abc', 'def._']); @@ -521,7 +521,7 @@ suite('SnippetController', () => { codeSnippet = '._foo'; controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getModel().getValue(), 'this._foo\nabc._foo\ndef._foo'); + assert.equal(editor.getModel()!.getValue(), 'this._foo\nabc._foo\ndef._foo'); }, ['this._', 'abc', 'def._']); @@ -535,7 +535,7 @@ suite('SnippetController', () => { codeSnippet = '._foo'; controller.insert(codeSnippet, 2, 0); - assert.equal(editor.getModel().getValue(), 'this._._foo\na._foo\ndef._._foo'); + assert.equal(editor.getModel()!.getValue(), 'this._._foo\na._foo\ndef._._foo'); }, ['this._', 'abc', 'def._']); @@ -551,7 +551,7 @@ suite('SnippetController', () => { codeSnippet = 'document'; controller.insert(codeSnippet, 3, 0); - assert.equal(editor.getModel().getValue(), '{document}\n{document && true}'); + assert.equal(editor.getModel()!.getValue(), '{document}\n{document && true}'); }, ['{foo}', '{foo && true}']); }); @@ -566,7 +566,7 @@ suite('SnippetController', () => { codeSnippet = 'for (var ${1:i}=0; ${1:i} { codeSnippet = 'for (let ${1:i}=0; ${1:i} expected=${actual.toString()}`); } assert.equal(s.length, 0); diff --git a/src/vs/editor/contrib/suggest/test/suggestMemory.test.ts b/src/vs/editor/contrib/suggest/test/suggestMemory.test.ts index 54e76d19e8567..3dda6f9f6fb5e 100644 --- a/src/vs/editor/contrib/suggest/test/suggestMemory.test.ts +++ b/src/vs/editor/contrib/suggest/test/suggestMemory.test.ts @@ -74,7 +74,7 @@ suite('SuggestMemories', function () { assert.equal(mem.select(buffer, pos, []), 0); mem.memorize(buffer, pos, items[0]); - mem.memorize(buffer, pos, null); + mem.memorize(buffer, pos, null!); }); test('LRUMemory', () => { diff --git a/src/vs/editor/contrib/suggest/test/suggestModel.test.ts b/src/vs/editor/contrib/suggest/test/suggestModel.test.ts index 49048da13390d..db6af2b0fbf4f 100644 --- a/src/vs/editor/contrib/suggest/test/suggestModel.test.ts +++ b/src/vs/editor/contrib/suggest/test/suggestModel.test.ts @@ -71,7 +71,7 @@ suite('SuggestModel - Context', function () { this._register(TokenizationRegistry.register(this.getLanguageIdentifier().language, { getInitialState: (): IState => NULL_STATE, - tokenize: undefined, + tokenize: undefined!, tokenize2: (line: string, state: IState): TokenizationResult2 => { const tokensArr: number[] = []; let prevLanguageId: LanguageIdentifier | undefined = undefined; @@ -418,7 +418,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () { return withOracle((model, editor) => { - editor.getModel().setValue('fo'); + editor.getModel()!.setValue('fo'); editor.setPosition({ lineNumber: 1, column: 3 }); return assertEvent(model.onDidSuggest, () => { @@ -443,7 +443,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () { return withOracle((model, editor) => { - editor.getModel().setValue('fo'); + editor.getModel()!.setValue('fo'); editor.setPosition({ lineNumber: 1, column: 3 }); return assertEvent(model.onDidSuggest, () => { @@ -480,7 +480,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () { return withOracle((model, editor) => { - editor.getModel().setValue('foo'); + editor.getModel()!.setValue('foo'); editor.setPosition({ lineNumber: 1, column: 4 }); return assertEvent(model.onDidSuggest, () => { @@ -517,7 +517,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () { return withOracle((model, editor) => { - editor.getModel().setValue('foo'); + editor.getModel()!.setValue('foo'); editor.setPosition({ lineNumber: 1, column: 4 }); return assertEvent(model.onDidSuggest, () => { @@ -548,7 +548,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () { triggerCharacters: ['.'], provideCompletionItems(doc, pos, context): CompletionList { assert.equal(context.triggerKind, CompletionTriggerKind.TriggerCharacter); - triggerCharacter = context.triggerCharacter; + triggerCharacter = context.triggerCharacter!; return { incomplete: false, suggestions: [ diff --git a/src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts b/src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts index baa5c568f05c4..395c611acf2f3 100644 --- a/src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts +++ b/src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts @@ -22,7 +22,7 @@ suite('TokenizationSupport2Adapter', () => { class MockTokenTheme extends TokenTheme { private counter = 0; constructor() { - super(null, null); + super(null!, null!); } public match(languageId: LanguageId, token: string): number { return ( diff --git a/src/vs/platform/commands/test/commands.test.ts b/src/vs/platform/commands/test/commands.test.ts index 3ec89a65d3a64..054c0ff499780 100644 --- a/src/vs/platform/commands/test/commands.test.ts +++ b/src/vs/platform/commands/test/commands.test.ts @@ -8,13 +8,13 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands'; suite('Command Tests', function () { test('register command - no handler', function () { - assert.throws(() => CommandsRegistry.registerCommand('foo', null)); + assert.throws(() => CommandsRegistry.registerCommand('foo', null!)); }); test('register/dispose', () => { const command = function () { }; const reg = CommandsRegistry.registerCommand('foo', command); - assert.ok(CommandsRegistry.getCommand('foo').handler === command); + assert.ok(CommandsRegistry.getCommand('foo')!.handler === command); reg.dispose(); assert.ok(CommandsRegistry.getCommand('foo') === undefined); }); @@ -25,23 +25,23 @@ suite('Command Tests', function () { // dispose overriding command let reg1 = CommandsRegistry.registerCommand('foo', command1); - assert.ok(CommandsRegistry.getCommand('foo').handler === command1); + assert.ok(CommandsRegistry.getCommand('foo')!.handler === command1); let reg2 = CommandsRegistry.registerCommand('foo', command2); - assert.ok(CommandsRegistry.getCommand('foo').handler === command2); + assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2); reg2.dispose(); - assert.ok(CommandsRegistry.getCommand('foo').handler === command1); + assert.ok(CommandsRegistry.getCommand('foo')!.handler === command1); reg1.dispose(); assert.ok(CommandsRegistry.getCommand('foo') === void 0); // dispose override command first reg1 = CommandsRegistry.registerCommand('foo', command1); reg2 = CommandsRegistry.registerCommand('foo', command2); - assert.ok(CommandsRegistry.getCommand('foo').handler === command2); + assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2); reg1.dispose(); - assert.ok(CommandsRegistry.getCommand('foo').handler === command2); + assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2); reg2.dispose(); assert.ok(CommandsRegistry.getCommand('foo') === void 0); @@ -68,10 +68,10 @@ suite('Command Tests', function () { } }); - CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined, 'string']); - CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined, 'string']); - assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined, 'string'])); - assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined, 1]), true); + CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined!, 'string']); + CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined!, 'string']); + assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 'string'])); + assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined!, 1]), true); }); }); diff --git a/src/vs/platform/extensionManagement/test/electron-browser/extensionEnablementService.test.ts b/src/vs/platform/extensionManagement/test/electron-browser/extensionEnablementService.test.ts index b898a8f1350b0..e4b15d11db7d1 100644 --- a/src/vs/platform/extensionManagement/test/electron-browser/extensionEnablementService.test.ts +++ b/src/vs/platform/extensionManagement/test/electron-browser/extensionEnablementService.test.ts @@ -50,7 +50,7 @@ suite('ExtensionEnablementService Test', () => { setup(() => { instantiationService = new TestInstantiationService(); - instantiationService.stub(IExtensionManagementService, { onDidUninstallExtension: didUninstallEvent.event, onDidInstallExtension: didInstallEvent.event, getInstalled: () => Promise.resolve([]) } as IExtensionManagementService); + instantiationService.stub(IExtensionManagementService, { onDidUninstallExtension: didUninstallEvent.event, onDidInstallExtension: didInstallEvent.event, getInstalled: () => Promise.resolve([] as ILocalExtension[]) } as IExtensionManagementService); testObject = new TestExtensionEnablementService(instantiationService); }); diff --git a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts index d75b1cbdec545..1a3107370cb49 100644 --- a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts @@ -77,15 +77,15 @@ suite('AbstractKeybindingService', () => { altKey: keybinding.altKey, metaKey: keybinding.metaKey, keyCode: keybinding.keyCode, - code: null - }, null); + code: null! + }, null!); } } - let createTestKeybindingService: (items: ResolvedKeybindingItem[], contextValue?: any) => TestKeybindingService = null; + let createTestKeybindingService: (items: ResolvedKeybindingItem[], contextValue?: any) => TestKeybindingService = null!; let currentContextValue: IContext | null = null; - let executeCommandCalls: { commandId: string; args: any[]; }[] = null; - let showMessageCalls: { sev: Severity, message: any; }[] = null; + let executeCommandCalls: { commandId: string; args: any[]; }[] = null!; + let showMessageCalls: { sev: Severity, message: any; }[] = null!; let statusMessageCalls: string[] | null = null; let statusMessageCallsDisposed: string[] | null = null; @@ -99,12 +99,12 @@ suite('AbstractKeybindingService', () => { let contextKeyService: IContextKeyService = { _serviceBrand: undefined, - dispose: undefined, - onDidChangeContext: undefined, - createKey: undefined, - contextMatchesRules: undefined, - getContextKeyValue: undefined, - createScoped: undefined, + dispose: undefined!, + onDidChangeContext: undefined!, + createKey: undefined!, + contextMatchesRules: undefined!, + getContextKeyValue: undefined!, + createScoped: undefined!, getContext: (target: IContextKeyServiceTarget): any => { return currentContextValue; } @@ -147,12 +147,12 @@ suite('AbstractKeybindingService', () => { let statusbarService: IStatusbarService = { _serviceBrand: undefined, - addEntry: undefined, + addEntry: undefined!, setStatusMessage: (message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable => { - statusMessageCalls.push(message); + statusMessageCalls!.push(message); return { dispose: () => { - statusMessageCallsDisposed.push(message); + statusMessageCallsDisposed!.push(message); } }; } @@ -166,15 +166,15 @@ suite('AbstractKeybindingService', () => { teardown(() => { currentContextValue = null; - executeCommandCalls = null; - showMessageCalls = null; - createTestKeybindingService = null; + executeCommandCalls = null!; + showMessageCalls = null!; + createTestKeybindingService = null!; statusMessageCalls = null; statusMessageCallsDisposed = null; }); function kbItem(keybinding: number, command: string, when: ContextKeyExpr | null = null): ResolvedKeybindingItem { - const resolvedKeybinding = (keybinding !== 0 ? new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS) : null); + const resolvedKeybinding = (keybinding !== 0 ? new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS) : null); return new ResolvedKeybindingItem( resolvedKeybinding, command, @@ -185,8 +185,8 @@ suite('AbstractKeybindingService', () => { } function toUsLabel(keybinding: number): string { - const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS); - return usResolvedKeybinding.getLabel(); + const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS); + return usResolvedKeybinding.getLabel()!; } test('issue #16498: chord mode is quit for invalid chords', () => { diff --git a/src/vs/platform/storage/test/node/storageService.test.ts b/src/vs/platform/storage/test/node/storageService.test.ts index 411af79487d8a..3e4da70f09631 100644 --- a/src/vs/platform/storage/test/node/storageService.test.ts +++ b/src/vs/platform/storage/test/node/storageService.test.ts @@ -30,10 +30,10 @@ suite('StorageService', () => { const storage = new TestStorageService(); storage.store('Monaco.IDE.Core.Storage.Test.remove', 'foobar', scope); - strictEqual('foobar', storage.get('Monaco.IDE.Core.Storage.Test.remove', scope, void 0)); + strictEqual('foobar', storage.get('Monaco.IDE.Core.Storage.Test.remove', scope, (void 0)!)); storage.remove('Monaco.IDE.Core.Storage.Test.remove', scope); - ok(!storage.get('Monaco.IDE.Core.Storage.Test.remove', scope, void 0)); + ok(!storage.get('Monaco.IDE.Core.Storage.Test.remove', scope, (void 0)!)); } test('Get Data, Integer, Boolean (global, in-memory)', () => { @@ -55,22 +55,22 @@ suite('StorageService', () => { strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, false), false); storage.store('Monaco.IDE.Core.Storage.Test.get', 'foobar', scope); - strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, void 0), 'foobar'); + strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, (void 0)!), 'foobar'); storage.store('Monaco.IDE.Core.Storage.Test.get', '', scope); - strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, void 0), ''); + strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, (void 0)!), ''); storage.store('Monaco.IDE.Core.Storage.Test.getInteger', 5, scope); - strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, void 0), 5); + strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, (void 0)!), 5); storage.store('Monaco.IDE.Core.Storage.Test.getInteger', 0, scope); - strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, void 0), 0); + strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, (void 0)!), 0); storage.store('Monaco.IDE.Core.Storage.Test.getBoolean', true, scope); - strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, void 0), true); + strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, (void 0)!), true); storage.store('Monaco.IDE.Core.Storage.Test.getBoolean', false, scope); - strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, void 0), false); + strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, (void 0)!), false); strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getDefault', scope, 'getDefault'), 'getDefault'); strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getIntegerDefault', scope, 5), 5); diff --git a/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts b/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts index f40ff181d7ed6..d21422f49e27c 100644 --- a/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts @@ -17,8 +17,8 @@ suite('Telemetry - common properties', function () { const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'telemetryservice'); const installSource = path.join(parentDir, 'installSource'); - const commit: string = void 0; - const version: string = void 0; + const commit: string = (void 0)!; + const version: string = (void 0)!; let testStorageService: IStorageService; setup(() => { diff --git a/src/vs/platform/theme/test/electron-browser/colorRegistry.releaseTest.ts b/src/vs/platform/theme/test/electron-browser/colorRegistry.releaseTest.ts index 5cb6611edeabf..30e0d0ca05eff 100644 --- a/src/vs/platform/theme/test/electron-browser/colorRegistry.releaseTest.ts +++ b/src/vs/platform/theme/test/electron-browser/colorRegistry.releaseTest.ts @@ -41,7 +41,7 @@ suite('Color Registry', function () { test('all colors documented', async function () { const reqContext = await request({ url: 'https://raw.githubusercontent.com/Microsoft/vscode-docs/vnext/docs/getstarted/theme-color-reference.md' }, CancellationToken.None); - const content = await asText(reqContext); + const content = (await asText(reqContext))!; const expression = /\-\s*\`([\w\.]+)\`: (.*)/g; diff --git a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts index 4e24cd819f8ec..cc09cbec88606 100644 --- a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts +++ b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts @@ -177,9 +177,9 @@ suite('WorkspacesMainService', () => { workspace.configPath = newPath; const resolved = service.resolveWorkspaceSync(workspace.configPath); - assert.equal(2, resolved.folders.length); - assert.equal(resolved.configPath, workspace.configPath); - assert.ok(resolved.id); + assert.equal(2, resolved!.folders.length); + assert.equal(resolved!.configPath, workspace.configPath); + assert.ok(resolved!.id); fs.writeFileSync(workspace.configPath, JSON.stringify({ something: 'something' })); // invalid workspace const resolvedInvalid = service.resolveWorkspaceSync(workspace.configPath); @@ -192,7 +192,7 @@ suite('WorkspacesMainService', () => { fs.writeFileSync(workspace.configPath, JSON.stringify({ folders: [{ path: './ticino-playground/lib' }] })); const resolved = service.resolveWorkspaceSync(workspace.configPath); - assert.equal(resolved.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'lib')).fsPath); + assert.equal(resolved!.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'lib')).fsPath); }); }); @@ -201,7 +201,7 @@ suite('WorkspacesMainService', () => { fs.writeFileSync(workspace.configPath, JSON.stringify({ folders: [{ path: './ticino-playground/lib/../other' }] })); const resolved = service.resolveWorkspaceSync(workspace.configPath); - assert.equal(resolved.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'other')).fsPath); + assert.equal(resolved!.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'other')).fsPath); }); }); @@ -210,7 +210,7 @@ suite('WorkspacesMainService', () => { fs.writeFileSync(workspace.configPath, JSON.stringify({ folders: [{ path: 'ticino-playground/lib' }] })); const resolved = service.resolveWorkspaceSync(workspace.configPath); - assert.equal(resolved.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'lib')).fsPath); + assert.equal(resolved!.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'lib')).fsPath); }); }); @@ -219,7 +219,7 @@ suite('WorkspacesMainService', () => { fs.writeFileSync(workspace.configPath, '{ "folders": [ { "path": "./ticino-playground/lib" } , ] }'); // trailing comma const resolved = service.resolveWorkspaceSync(workspace.configPath); - assert.equal(resolved.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'lib')).fsPath); + assert.equal(resolved!.folders[0].uri.fsPath, URI.file(path.join(path.dirname(workspace.configPath), 'ticino-playground', 'lib')).fsPath); }); }); diff --git a/src/vs/workbench/parts/debug/test/browser/debugANSIHandling.test.ts b/src/vs/workbench/parts/debug/test/browser/debugANSIHandling.test.ts index c8e8ed027509d..fe95a2e055a57 100644 --- a/src/vs/workbench/parts/debug/test/browser/debugANSIHandling.test.ts +++ b/src/vs/workbench/parts/debug/test/browser/debugANSIHandling.test.ts @@ -34,7 +34,7 @@ suite('Debug - ANSI Handling', () => { assert.equal(2, root.children.length); - child = root.firstChild; + child = root.firstChild!; if (child instanceof HTMLSpanElement) { assert.equal('content1', child.textContent); assert(dom.hasClass(child, 'class1')); @@ -43,7 +43,7 @@ suite('Debug - ANSI Handling', () => { assert.fail('Unexpected assertion error'); } - child = root.lastChild; + child = root.lastChild!; if (child instanceof HTMLSpanElement) { assert.equal('content2', child.textContent); assert(dom.hasClass(child, 'class2')); @@ -62,12 +62,12 @@ suite('Debug - ANSI Handling', () => { function getSequenceOutput(sequence: string): HTMLSpanElement { const root: HTMLSpanElement = handleANSIOutput(sequence, linkDetector); assert.equal(1, root.children.length); - const child: Node = root.lastChild; + const child: Node = root.lastChild!; if (child instanceof HTMLSpanElement) { return child; } else { assert.fail('Unexpected assertion error'); - return null; + return null!; } } diff --git a/src/vs/workbench/parts/debug/test/node/debugger.test.ts b/src/vs/workbench/parts/debug/test/node/debugger.test.ts index d4f9160f8dde4..2c89689d5d154 100644 --- a/src/vs/workbench/parts/debug/test/node/debugger.test.ts +++ b/src/vs/workbench/parts/debug/test/node/debugger.test.ts @@ -37,7 +37,7 @@ suite('Debug - Debugger', () => { } } }, - variables: null, + variables: null!, initialConfigurations: [ { name: 'Mock-Debug', @@ -57,7 +57,7 @@ suite('Debug - Debugger', () => { extensionLocation: URI.file(extensionFolderPath), isBuiltin: false, isUnderDevelopment: false, - engines: null, + engines: null!, contributes: { 'debuggers': [ debuggerContribution @@ -74,7 +74,7 @@ suite('Debug - Debugger', () => { extensionLocation: URI.file('/e1/b/c/'), isBuiltin: false, isUnderDevelopment: false, - engines: null, + engines: null!, contributes: { 'debuggers': [ { @@ -97,7 +97,7 @@ suite('Debug - Debugger', () => { extensionLocation: URI.file('/e2/b/c/'), isBuiltin: false, isUnderDevelopment: false, - engines: null, + engines: null!, contributes: { 'debuggers': [ { @@ -130,11 +130,11 @@ suite('Debug - Debugger', () => { const testResourcePropertiesService = new TestTextResourcePropertiesService(configurationService); setup(() => { - _debugger = new Debugger(configurationManager, debuggerContribution, extensionDescriptor0, configurationService, testResourcePropertiesService, undefined, undefined, undefined); + _debugger = new Debugger(configurationManager, debuggerContribution, extensionDescriptor0, configurationService, testResourcePropertiesService, undefined!, undefined!, undefined!); }); teardown(() => { - _debugger = null; + _debugger = null!; }); test('attributes', () => { @@ -143,8 +143,8 @@ suite('Debug - Debugger', () => { const ae = ExecutableDebugAdapter.platformAdapterExecutable([extensionDescriptor0], 'mock'); - assert.equal(ae.command, paths.join(extensionFolderPath, debuggerContribution.program)); - assert.deepEqual(ae.args, debuggerContribution.args); + assert.equal(ae!.command, paths.join(extensionFolderPath, debuggerContribution.program)); + assert.deepEqual(ae!.args, debuggerContribution.args); }); test('schema attributes', () => { @@ -155,14 +155,14 @@ suite('Debug - Debugger', () => { }); assert.equal(schemaAttribute['additionalProperties'], false); - assert.equal(!!schemaAttribute['properties']['request'], true); - assert.equal(!!schemaAttribute['properties']['name'], true); - assert.equal(!!schemaAttribute['properties']['type'], true); - assert.equal(!!schemaAttribute['properties']['preLaunchTask'], true); + assert.equal(!!schemaAttribute['properties']!['request'], true); + assert.equal(!!schemaAttribute['properties']!['name'], true); + assert.equal(!!schemaAttribute['properties']!['type'], true); + assert.equal(!!schemaAttribute['properties']!['preLaunchTask'], true); }); test('merge platform specific attributes', () => { - const ae = ExecutableDebugAdapter.platformAdapterExecutable([extensionDescriptor1, extensionDescriptor2], 'mock'); + const ae = ExecutableDebugAdapter.platformAdapterExecutable([extensionDescriptor1, extensionDescriptor2], 'mock')!; assert.equal(ae.command, platform.isLinux ? 'linuxRuntime' : (platform.isMacintosh ? 'osxRuntime' : 'winRuntime')); const xprogram = platform.isLinux ? 'linuxProgram' : (platform.isMacintosh ? 'osxProgram' : 'winProgram'); assert.deepEqual(ae.args, ['rarg', '/e2/b/c/' + xprogram, 'parg']); diff --git a/src/vs/workbench/parts/experiments/test/electron-browser/experimentService.test.ts b/src/vs/workbench/parts/experiments/test/electron-browser/experimentService.test.ts index 6b117c4c2b25a..fae51e767ad44 100644 --- a/src/vs/workbench/parts/experiments/test/electron-browser/experimentService.test.ts +++ b/src/vs/workbench/parts/experiments/test/electron-browser/experimentService.test.ts @@ -27,7 +27,13 @@ import { URI } from 'vs/base/common/uri'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { lastSessionDateStorageKey } from 'vs/platform/telemetry/node/workbenchCommonProperties'; -let experimentData = { +interface ExperimentSettings { + enabled?: boolean; + id?: string; + state?: ExperimentState; +} + +let experimentData: { [i: string]: any } = { experiments: [] }; @@ -495,9 +501,9 @@ suite('Experiment Service', () => { ] }; - let storageDataExperiment1 = { enabled: false }; - let storageDataExperiment2 = { enabled: false }; - let storageDataAllExperiments = ['experiment1', 'experiment2', 'experiment3']; + let storageDataExperiment1: ExperimentSettings | null = { enabled: false }; + let storageDataExperiment2: ExperimentSettings | null = { enabled: false }; + let storageDataAllExperiments: string[] | null = ['experiment1', 'experiment2', 'experiment3']; instantiationService.stub(IStorageService, { get: (a, b, c) => { switch (a) { @@ -554,8 +560,8 @@ suite('Experiment Service', () => { assert.equal(!!storageDataExperiment2, false); }); return Promise.all([disabledExperiment, deletedExperiment]).then(() => { - assert.equal(storageDataAllExperiments.length, 1); - assert.equal(storageDataAllExperiments[0], 'experiment3'); + assert.equal(storageDataAllExperiments!.length, 1); + assert.equal(storageDataAllExperiments![0], 'experiment3'); }); }); @@ -565,11 +571,11 @@ suite('Experiment Service', () => { experiments: null }; - let storageDataExperiment1 = { enabled: true, state: ExperimentState.Run }; - let storageDataExperiment2 = { enabled: true, state: ExperimentState.NoRun }; - let storageDataExperiment3 = { enabled: true, state: ExperimentState.Evaluating }; - let storageDataExperiment4 = { enabled: true, state: ExperimentState.Complete }; - let storageDataAllExperiments = ['experiment1', 'experiment2', 'experiment3', 'experiment4']; + let storageDataExperiment1: ExperimentSettings | null = { enabled: true, state: ExperimentState.Run }; + let storageDataExperiment2: ExperimentSettings | null = { enabled: true, state: ExperimentState.NoRun }; + let storageDataExperiment3: ExperimentSettings | null = { enabled: true, state: ExperimentState.Evaluating }; + let storageDataExperiment4: ExperimentSettings | null = { enabled: true, state: ExperimentState.Complete }; + let storageDataAllExperiments: string[] | null = ['experiment1', 'experiment2', 'experiment3', 'experiment4']; instantiationService.stub(IStorageService, { get: (a, b, c) => { switch (a) { @@ -718,9 +724,9 @@ suite('Experiment Service', () => { assert.equal(result.length, 3); assert.equal(result[0].id, 'simple-experiment'); assert.equal(result[1].id, 'custom-experiment'); - assert.equal(result[1].action.properties, customProperties); + assert.equal(result[1].action!.properties, customProperties); assert.equal(result[2].id, 'custom-experiment-no-properties'); - assert.equal(!!result[2].action.properties, true); + assert.equal(!!result[2].action!.properties, true); }); const prompt = testObject.getExperimentsByType(ExperimentActionType.Prompt).then(result => { assert.equal(result.length, 2); diff --git a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts index b0dd6e41b18eb..9e0266724f221 100644 --- a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts +++ b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsActions.test.ts @@ -1285,7 +1285,7 @@ suite('ExtensionsActions Test', () => { } function aPage(...objects: T[]): IPager { - return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null }; + return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null! }; } }); diff --git a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts index 78d93df69e7a2..662d97098fe27 100644 --- a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts +++ b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsTipsService.test.ts @@ -139,18 +139,18 @@ const mockTestData = { }; function aPage(...objects: T[]): IPager { - return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null }; + return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null! }; } const noAssets: IGalleryExtensionAssets = { changelog: null, - download: null, - icon: null, + download: null!, + icon: null!, license: null, manifest: null, readme: null, repository: null, - coreTranslations: null + coreTranslations: null! }; function aGalleryExtension(name: string, properties: any = {}, galleryExtensionProperties: any = {}, assets: IGalleryExtensionAssets = noAssets): IGalleryExtension { @@ -235,7 +235,7 @@ suite('ExtensionsTipsService Test', () => { class TestNotificationService2 extends TestNotificationService { public prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions) { prompted = true; - return null; + return null!; } } diff --git a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts index 7984895518586..d93c65516c7fa 100644 --- a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts +++ b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsViews.test.ts @@ -324,10 +324,10 @@ suite('ExtensionsListView Tests', () => { return testableView.show('@recommended:workspace').then(result => { assert.ok(target.calledOnce); const options: IQueryOptions = target.args[0][0]; - assert.equal(options.names.length, workspaceRecommendedExtensions.length); + assert.equal(options.names!.length, workspaceRecommendedExtensions.length); assert.equal(result.length, workspaceRecommendedExtensions.length); for (let i = 0; i < workspaceRecommendedExtensions.length; i++) { - assert.equal(options.names[i], workspaceRecommendedExtensions[i].identifier.id); + assert.equal(options.names![i], workspaceRecommendedExtensions[i].identifier.id); assert.equal(result.get(i).identifier.id, workspaceRecommendedExtensions[i].identifier.id); } }); @@ -345,10 +345,10 @@ suite('ExtensionsListView Tests', () => { const options: IQueryOptions = target.args[0][0]; assert.ok(target.calledOnce); - assert.equal(options.names.length, allRecommendedExtensions.length); + assert.equal(options.names!.length, allRecommendedExtensions.length); assert.equal(result.length, allRecommendedExtensions.length); for (let i = 0; i < allRecommendedExtensions.length; i++) { - assert.equal(options.names[i], allRecommendedExtensions[i].identifier.id); + assert.equal(options.names![i], allRecommendedExtensions[i].identifier.id); assert.equal(result.get(i).identifier.id, allRecommendedExtensions[i].identifier.id); } }); @@ -369,10 +369,10 @@ suite('ExtensionsListView Tests', () => { const options: IQueryOptions = target.args[0][0]; assert.ok(target.calledOnce); - assert.equal(options.names.length, allRecommendedExtensions.length); + assert.equal(options.names!.length, allRecommendedExtensions.length); assert.equal(result.length, allRecommendedExtensions.length); for (let i = 0; i < allRecommendedExtensions.length; i++) { - assert.equal(options.names[i], allRecommendedExtensions[i].identifier.id); + assert.equal(options.names![i], allRecommendedExtensions[i].identifier.id); assert.equal(result.get(i).identifier.id, allRecommendedExtensions[i].identifier.id); } }); @@ -392,10 +392,10 @@ suite('ExtensionsListView Tests', () => { assert.ok(experimentTarget.calledOnce); assert.ok(queryTarget.calledOnce); - assert.equal(options.names.length, curatedList.length); + assert.equal(options.names!.length, curatedList.length); assert.equal(result.length, curatedList.length); for (let i = 0; i < curatedList.length; i++) { - assert.equal(options.names[i], curatedList[i].identifier.id); + assert.equal(options.names![i], curatedList[i].identifier.id); assert.equal(result.get(i).identifier.id, curatedList[i].identifier.id); } assert.equal(curatedKey, 'mykey'); @@ -518,7 +518,7 @@ suite('ExtensionsListView Tests', () => { } function aPage(...objects: T[]): IPager { - return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null }; + return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null! }; } }); diff --git a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsWorkbenchService.test.ts b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsWorkbenchService.test.ts index dac3ad9d2bd06..3205c28f36dc5 100644 --- a/src/vs/workbench/parts/extensions/test/electron-browser/extensionsWorkbenchService.test.ts +++ b/src/vs/workbench/parts/extensions/test/electron-browser/extensionsWorkbenchService.test.ts @@ -488,28 +488,28 @@ suite('ExtensionsWorkbenchServiceTest', () => { return testObject.queryGallery().then(page => { const extension = page.firstPage[0]; return testObject.loadDependencies(extension, CancellationToken.None).then(actual => { - assert.ok(actual.hasDependencies); - assert.equal(extension, actual.extension); - assert.equal(null, actual.dependent); - assert.equal(3, actual.dependencies.length); - assert.equal('pub.a', actual.identifier); + assert.ok(actual!.hasDependencies); + assert.equal(extension, actual!.extension); + assert.equal(null, actual!.dependent); + assert.equal(3, actual!.dependencies.length); + assert.equal('pub.a', actual!.identifier); let dependent = actual; - actual = dependent.dependencies[0]; + actual = dependent!.dependencies[0]; assert.ok(!actual.hasDependencies); assert.equal('pub.b', actual.extension.identifier.id); assert.equal('pub.b', actual.identifier); assert.equal(dependent, actual.dependent); assert.equal(0, actual.dependencies.length); - actual = dependent.dependencies[1]; + actual = dependent!.dependencies[1]; assert.ok(!actual.hasDependencies); assert.equal('pub.c', actual.extension.identifier.id); assert.equal('pub.c', actual.identifier); assert.equal(dependent, actual.dependent); assert.equal(0, actual.dependencies.length); - actual = dependent.dependencies[2]; + actual = dependent!.dependencies[2]; assert.ok(!actual.hasDependencies); assert.equal('pub.d', actual.extension.identifier.id); assert.equal('pub.d', actual.identifier); @@ -527,21 +527,21 @@ suite('ExtensionsWorkbenchServiceTest', () => { return testObject.queryGallery().then(page => { const extension = page.firstPage[0]; return testObject.loadDependencies(extension, CancellationToken.None).then(actual => { - assert.ok(actual.hasDependencies); - assert.equal(extension, actual.extension); - assert.equal(null, actual.dependent); - assert.equal(2, actual.dependencies.length); - assert.equal('pub.a', actual.identifier); + assert.ok(actual!.hasDependencies); + assert.equal(extension, actual!.extension); + assert.equal(null, actual!.dependent); + assert.equal(2, actual!.dependencies.length); + assert.equal('pub.a', actual!.identifier); let dependent = actual; - actual = dependent.dependencies[0]; + actual = dependent!.dependencies[0]!; assert.ok(!actual.hasDependencies); assert.equal('pub.b', actual.extension.identifier.id); assert.equal('pub.b', actual.identifier); assert.equal(dependent, actual.dependent); assert.equal(0, actual.dependencies.length); - actual = dependent.dependencies[1]; + actual = dependent!.dependencies[1]!; assert.ok(!actual.hasDependencies); assert.equal('pub.a', actual.extension.identifier.id); assert.equal('pub.a', actual.identifier); @@ -559,21 +559,21 @@ suite('ExtensionsWorkbenchServiceTest', () => { return testObject.queryGallery().then(page => { const extension = page.firstPage[0]; return testObject.loadDependencies(extension, CancellationToken.None).then(actual => { - assert.ok(actual.hasDependencies); - assert.equal(extension, actual.extension); - assert.equal(null, actual.dependent); - assert.equal(2, actual.dependencies.length); - assert.equal('pub.a', actual.identifier); + assert.ok(actual!.hasDependencies); + assert.equal(extension, actual!.extension); + assert.equal(null, actual!.dependent); + assert.equal(2, actual!.dependencies.length); + assert.equal('pub.a', actual!.identifier); let dependent = actual; - actual = dependent.dependencies[0]; + actual = dependent!.dependencies[0]!; assert.ok(!actual.hasDependencies); assert.equal(null, actual.extension); assert.equal('pub.b', actual.identifier); assert.equal(dependent, actual.dependent); assert.equal(0, actual.dependencies.length); - actual = dependent.dependencies[1]; + actual = dependent!.dependencies[1]!; assert.ok(!actual.hasDependencies); assert.equal('pub.a', actual.extension.identifier.id); assert.equal('pub.a', actual.identifier); @@ -593,14 +593,14 @@ suite('ExtensionsWorkbenchServiceTest', () => { return testObject.queryGallery().then(page => { const extension = page.firstPage[0]; return testObject.loadDependencies(extension, CancellationToken.None).then(actual => { - assert.ok(actual.hasDependencies); - assert.equal(extension, actual.extension); - assert.equal(null, actual.dependent); - assert.equal(2, actual.dependencies.length); - assert.equal('pub.a', actual.identifier); + assert.ok(actual!.hasDependencies); + assert.equal(extension, actual!.extension); + assert.equal(null, actual!.dependent); + assert.equal(2, actual!.dependencies.length); + assert.equal('pub.a', actual!.identifier); let dependent = actual; - actual = dependent.dependencies[0]; + actual = dependent!.dependencies[0]!; assert.ok(!actual.hasDependencies); assert.equal('pub.inbuilt', actual.extension.identifier.id); assert.equal('pub.inbuilt', actual.identifier); @@ -608,7 +608,7 @@ suite('ExtensionsWorkbenchServiceTest', () => { assert.equal(0, actual.dependencies.length); - actual = dependent.dependencies[1]; + actual = dependent!.dependencies[1]!; assert.ok(!actual.hasDependencies); assert.equal('pub.a', actual.extension.identifier.id); assert.equal('pub.a', actual.identifier); @@ -631,20 +631,20 @@ suite('ExtensionsWorkbenchServiceTest', () => { return testObject.queryGallery().then(page => { const extension = page.firstPage[0]; return testObject.loadDependencies(extension, CancellationToken.None).then(a => { - assert.ok(a.hasDependencies); - assert.equal(extension, a.extension); - assert.equal(null, a.dependent); - assert.equal(2, a.dependencies.length); - assert.equal('pub.a', a.identifier); + assert.ok(a!.hasDependencies); + assert.equal(extension, a!.extension); + assert.equal(null, a!.dependent); + assert.equal(2, a!.dependencies.length); + assert.equal('pub.a', a!.identifier); - let b = a.dependencies[0]; + let b = a!.dependencies[0]; assert.ok(b.hasDependencies); assert.equal('pub.b', b.extension.identifier.id); assert.equal('pub.b', b.identifier); assert.equal(a, b.dependent); assert.equal(2, b.dependencies.length); - let c = a.dependencies[1]; + let c = a!.dependencies[1]; assert.ok(c.hasDependencies); assert.equal('pub.c', c.extension.identifier.id); assert.equal('pub.c', c.identifier); @@ -686,7 +686,7 @@ suite('ExtensionsWorkbenchServiceTest', () => { assert.equal(c, d.dependent); assert.equal(0, d.dependencies.length); - c = a.dependencies[1]; + c = a!.dependencies[1]; d = c.dependencies[0]; assert.ok(d.hasDependencies); assert.equal('pub.d', d.extension.identifier.id); @@ -1192,13 +1192,13 @@ suite('ExtensionsWorkbenchServiceTest', () => { const noAssets: IGalleryExtensionAssets = { changelog: null, - download: null, - icon: null, + download: null!, + icon: null!, license: null, manifest: null, readme: null, repository: null, - coreTranslations: null + coreTranslations: null! }; function aGalleryExtension(name: string, properties: any = {}, galleryExtensionProperties: any = {}, assets: IGalleryExtensionAssets = noAssets): IGalleryExtension { @@ -1211,7 +1211,7 @@ suite('ExtensionsWorkbenchServiceTest', () => { } function aPage(...objects: T[]): IPager { - return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null }; + return { firstPage: objects, total: objects.length, pageSize: objects.length, getPage: () => null! }; } function eventToPromise(event: Event, count: number = 1): Promise { diff --git a/src/vs/workbench/parts/files/test/electron-browser/explorerModel.test.ts b/src/vs/workbench/parts/files/test/electron-browser/explorerModel.test.ts index b4133dfedd2ce..e3e14e7d4d65b 100644 --- a/src/vs/workbench/parts/files/test/electron-browser/explorerModel.test.ts +++ b/src/vs/workbench/parts/files/test/electron-browser/explorerModel.test.ts @@ -35,7 +35,7 @@ suite('Files - View Model', () => { assert.strictEqual(s.name, 'sName'); assert.strictEqual(s.isDirectory, true); assert.strictEqual(s.mtime, new Date(d).getTime()); - assert.strictEqual(s.getChildrenArray().length, 0); + assert.strictEqual(s.getChildrenArray()!.length, 0); s = createStat('/path/to/stat', 'sName', false, false, 8096, d); assert(isUndefinedOrNull(s.getChildrenArray())); @@ -50,14 +50,14 @@ suite('Files - View Model', () => { s.addChild(child1); - assert(s.getChildrenArray().length === 1); + assert(s.getChildrenArray()!.length === 1); s.removeChild(child1); s.addChild(child1); - assert(s.getChildrenArray().length === 1); + assert(s.getChildrenArray()!.length === 1); s.removeChild(child1); - assert(s.getChildrenArray().length === 0); + assert(s.getChildrenArray()!.length === 0); // Assert that adding a child updates its path properly s.addChild(child4); @@ -78,9 +78,9 @@ suite('Files - View Model', () => { s4.move(s1); - assert.strictEqual(s3.getChildrenArray().length, 0); + assert.strictEqual(s3.getChildrenArray()!.length, 0); - assert.strictEqual(s1.getChildrenArray().length, 2); + assert.strictEqual(s1.getChildrenArray()!.length, 2); // Assert the new path of the moved element assert.strictEqual(s4.resource.fsPath, toResource('/' + s4.name).fsPath); @@ -197,7 +197,7 @@ suite('Files - View Model', () => { const sChild = createStat('/path/to/stat/alles.klar', 'alles.klar', true, true, 8096, d); s.addChild(sChild); - assert(validateFileName(s, null) !== null); + assert(validateFileName(s, null!) !== null); assert(validateFileName(s, '') !== null); assert(validateFileName(s, ' ') !== null); assert(validateFileName(s, 'Read Me') === null, 'name containing space'); @@ -277,7 +277,7 @@ suite('Files - View Model', () => { // Merge Child when isDirectoryResolved=false is a no-op merge2.addChild(new ExplorerItem(URI.file(join('C:\\', '/path/to/foo.html')), undefined, false, false, true, 'foo.html', Date.now(), d)); ExplorerItem.mergeLocalWithDisk(merge2, merge1); - assert.strictEqual(merge1.getChildrenArray().length, 0); + assert.strictEqual(merge1.getChildrenArray()!.length, 0); // Merge Child with isDirectoryResolved=true const child = new ExplorerItem(URI.file(join('C:\\', '/path/to/foo.html')), undefined, false, false, true, 'foo.html', Date.now(), d); @@ -285,13 +285,13 @@ suite('Files - View Model', () => { merge2.addChild(child); merge2.isDirectoryResolved = true; ExplorerItem.mergeLocalWithDisk(merge2, merge1); - assert.strictEqual(merge1.getChildrenArray().length, 1); - assert.strictEqual(merge1.getChild('foo.html').name, 'foo.html'); - assert.deepEqual(merge1.getChild('foo.html').parent, merge1, 'Check parent'); + assert.strictEqual(merge1.getChildrenArray()!.length, 1); + assert.strictEqual(merge1.getChild('foo.html')!.name, 'foo.html'); + assert.deepEqual(merge1.getChild('foo.html')!.parent, merge1, 'Check parent'); // Verify that merge does not replace existing children, but updates properties in that case const existingChild = merge1.getChild('foo.html'); ExplorerItem.mergeLocalWithDisk(merge2, merge1); - assert.ok(existingChild === merge1.getChild(existingChild.name)); + assert.ok(existingChild === merge1.getChild(existingChild!.name)); }); }); diff --git a/src/vs/workbench/parts/search/test/browser/openFileHandler.test.ts b/src/vs/workbench/parts/search/test/browser/openFileHandler.test.ts index df2516f3941a2..e9d82ebec3352 100644 --- a/src/vs/workbench/parts/search/test/browser/openFileHandler.test.ts +++ b/src/vs/workbench/parts/search/test/browser/openFileHandler.test.ts @@ -167,7 +167,7 @@ suite('CacheState', () => { cacheKey => cache.query(cacheKey), query => cache.load(query), cacheKey => cache.dispose(cacheKey), - previous + previous! ); } @@ -191,7 +191,7 @@ suite('CacheState', () => { public load(query: IFileQuery): Promise { const promise = new DeferredPromise(); - this.loading[query.cacheKey] = promise; + this.loading[query.cacheKey!] = promise; return promise.p; } diff --git a/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts b/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts index 51e291fc8e52c..8cfe81dba7f43 100644 --- a/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts +++ b/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts @@ -67,8 +67,8 @@ suite('Search - Viewlet', () => { const resultIterator = createIterator(result, 'auto'); const first = resultIterator.next(); - assert(!!first.value.children); - assert.equal((>>first.value.children).next().value.element.id(), 'file:///c%3A/foo>[2,1 -> 2,2]b'); + assert(!!first.value!.children); + assert.equal((>>first.value!.children).next().value!.element.id(), 'file:///c%3A/foo>[2,1 -> 2,2]b'); }); test('Comparer', () => { diff --git a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts index 6cc1ddd654bf6..57d3b65c16ebe 100644 --- a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts +++ b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts @@ -817,7 +817,7 @@ function assertEqualQueries(actual: ITextQuery | IFileQuery, expected: ITextQuer } if (expected.extraFileResources) { - assert.deepEqual(actual.extraFileResources.map(extraFile => extraFile.fsPath), expected.extraFileResources.map(extraFile => extraFile.fsPath)); + assert.deepEqual(actual.extraFileResources!.map(extraFile => extraFile.fsPath), expected.extraFileResources.map(extraFile => extraFile.fsPath)); delete expected.extraFileResources; delete actual.extraFileResources; } @@ -837,7 +837,7 @@ function assertEqualSearchPathResults(actual: ISearchPathsResult, expected: ISea assert.equal(actual.searchPaths && actual.searchPaths.length, expected.searchPaths && expected.searchPaths.length); if (actual.searchPaths) { actual.searchPaths.forEach((searchPath, i) => { - const expectedSearchPath = expected.searchPaths[i]; + const expectedSearchPath = expected.searchPaths![i]; assert.equal(searchPath.pattern, expectedSearchPath.pattern); assert.equal(searchPath.searchPath.toString(), expectedSearchPath.searchPath.toString()); }); @@ -885,7 +885,7 @@ function fixPath(...slashPathParts: string[]): string { return paths.join(...slashPathParts); } -function normalizeExpression(expression: IExpression): IExpression { +function normalizeExpression(expression: IExpression | undefined): IExpression | undefined { if (!expression) { return expression; } diff --git a/src/vs/workbench/parts/search/test/common/searchModel.test.ts b/src/vs/workbench/parts/search/test/common/searchModel.test.ts index 5918e0b1f8f3f..0a3bd31742fdf 100644 --- a/src/vs/workbench/parts/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/parts/search/test/common/searchModel.test.ts @@ -84,8 +84,8 @@ suite('SearchModel', () => { textSearch(query: ISearchQuery, token?: CancellationToken, onProgress?: (result: ISearchProgressItem) => void): Promise { return new Promise(resolve => { process.nextTick(() => { - results.forEach(onProgress); - resolve(complete); + results.forEach(onProgress!); + resolve(complete!); }); }); } diff --git a/src/vs/workbench/parts/search/test/common/searchResult.test.ts b/src/vs/workbench/parts/search/test/common/searchResult.test.ts index 66c5074904c49..50680e31632a2 100644 --- a/src/vs/workbench/parts/search/test/common/searchResult.test.ts +++ b/src/vs/workbench/parts/search/test/common/searchResult.test.ts @@ -32,7 +32,7 @@ suite('SearchResult', () => { }); test('Line Match', function () { - let fileMatch = aFileMatch('folder/file.txt', null); + let fileMatch = aFileMatch('folder/file.txt', null!); let lineMatch = new Match(fileMatch, ['foo bar'], new OneLineRange(0, 0, 3), new OneLineRange(1, 0, 3)); assert.equal(lineMatch.text(), 'foo bar'); assert.equal(lineMatch.range().startLineNumber, 2); @@ -307,7 +307,7 @@ suite('SearchResult', () => { aRawMatch('file://c:/2', new TextSearchMatch('preview 2', lineOneRange))]); - testObject.replaceAll(null); + testObject.replaceAll(null!); return voidPromise.then(() => assert.ok(testObject.isEmpty())); }); diff --git a/src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts b/src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts index 986a57782a9b3..30591e7eef12c 100644 --- a/src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts +++ b/src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts @@ -169,7 +169,7 @@ class CommandConfigurationBuilder { } public done(taskName: string): void { - this.result.args = this.result.args.map(arg => arg === '$name' ? taskName : arg); + this.result.args = this.result.args!.map(arg => arg === '$name' ? taskName : arg); this.presentationBuilder.done(); } } @@ -227,7 +227,7 @@ class CustomTaskBuilder { public problemMatcher(): ProblemMatcherBuilder { let builder = new ProblemMatcherBuilder(this); - this.result.configurationProperties.problemMatchers.push(builder.result); + this.result.configurationProperties.problemMatchers!.push(builder.result); return builder; } @@ -236,7 +236,7 @@ class CustomTaskBuilder { } public done(): void { - this.commandBuilder.done(this.result.configurationProperties.name); + this.commandBuilder.done(this.result.configurationProperties.name!); } } @@ -253,7 +253,7 @@ class ProblemMatcherBuilder { severity: undefined, fileLocation: FileLocationKind.Relative, filePrefix: '${workspaceFolder}', - pattern: undefined + pattern: undefined! }; } @@ -362,7 +362,7 @@ function testDefaultProblemMatcher(external: ExternalTaskRunnerConfiguration, re assert.strictEqual(result.custom.length, 1); let task = result.custom[0]; assert.ok(task); - assert.strictEqual(task.configurationProperties.problemMatchers.length, resolved); + assert.strictEqual(task.configurationProperties.problemMatchers!.length, resolved); } function testConfiguration(external: ExternalTaskRunnerConfiguration, builder: ConfiguationBuilder): void { @@ -409,8 +409,8 @@ class TaskGroupMap { return; } let expectedTaskMap: { [key: string]: boolean } = Object.create(null); - expectedTasks.forEach(task => expectedTaskMap[task.configurationProperties.name] = true); - actualTasks.forEach(task => delete expectedTaskMap[task.configurationProperties.name]); + expectedTasks.forEach(task => expectedTaskMap[task.configurationProperties.name!] = true); + actualTasks.forEach(task => delete expectedTaskMap[task.configurationProperties.name!]); assert.strictEqual(Object.keys(expectedTaskMap).length, 0); }); } @@ -430,9 +430,9 @@ function assertConfiguration(result: ParseResult, expected: Tasks.Task[]): void let actualId2Name: { [key: string]: string; } = Object.create(null); let actualTaskGroups = new TaskGroupMap(); actual.forEach(task => { - assert.ok(!actualTasks[task.configurationProperties.name]); - actualTasks[task.configurationProperties.name] = task; - actualId2Name[task._id] = task.configurationProperties.name; + assert.ok(!actualTasks[task.configurationProperties.name!]); + actualTasks[task.configurationProperties.name!] = task; + actualId2Name[task._id] = task.configurationProperties.name!; if (task.configurationProperties.group) { actualTaskGroups.add(task.configurationProperties.group, task); } @@ -440,8 +440,8 @@ function assertConfiguration(result: ParseResult, expected: Tasks.Task[]): void let expectedTasks: { [key: string]: Tasks.Task; } = Object.create(null); let expectedTaskGroup = new TaskGroupMap(); expected.forEach(task => { - assert.ok(!expectedTasks[task.configurationProperties.name]); - expectedTasks[task.configurationProperties.name] = task; + assert.ok(!expectedTasks[task.configurationProperties.name!]); + expectedTasks[task.configurationProperties.name!] = task; if (task.configurationProperties.group) { expectedTaskGroup.add(task.configurationProperties.group, task); } @@ -479,7 +479,7 @@ function assertTask(actual: Tasks.Task, expected: Tasks.Task) { function assertCommandConfiguration(actual: Tasks.CommandConfiguration, expected: Tasks.CommandConfiguration) { assert.strictEqual(typeof actual, typeof expected); if (actual && expected) { - assertPresentation(actual.presentation, expected.presentation); + assertPresentation(actual.presentation!, expected.presentation!); assert.strictEqual(actual.name, expected.name, 'name'); assert.strictEqual(actual.runtime, expected.runtime, 'runtime type'); assert.strictEqual(actual.suppressTaskName, expected.suppressTaskName, 'suppressTaskName'); @@ -1070,7 +1070,7 @@ suite('Tasks version 0.1.0', () => { applyTo(ApplyToKind.closedDocuments). severity(Severity.Warning). fileLocation(FileLocationKind.Absolute). - filePrefix(undefined). + filePrefix(undefined!). pattern(/abc/); testConfiguration(external, builder); }); diff --git a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts index eae982fa58743..2e0085dbe06d0 100644 --- a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts +++ b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts @@ -92,7 +92,7 @@ suite('BackupFileService', () => { service = new TestBackupFileService(workspaceResource, backupHome, workspacesJsonPath); return service.loadBackupResource(fooFile).then(resource => { assert.ok(resource); - assert.equal(path.basename(resource.fsPath), path.basename(fooBackupPath)); + assert.equal(path.basename(resource!.fsPath), path.basename(fooBackupPath)); return service.hasBackups().then(hasBackups => { assert.ok(hasBackups); }); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts index 86b0a03d1e93b..d29fd761b245e 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts @@ -122,7 +122,7 @@ suite('ConfigurationEditingService', () => { if (configuraitonService) { configuraitonService.dispose(); } - instantiationService = null; + instantiationService = null!; } } @@ -133,7 +133,7 @@ suite('ConfigurationEditingService', () => { } else { c(void 0); } - }).then(() => parentDir = null); + }).then(() => parentDir = null!); } test('errors cases - invalid key', () => { @@ -178,7 +178,7 @@ suite('ConfigurationEditingService', () => { test('do not notify error', () => { instantiationService.stub(ITextFileService, 'isDirty', true); const target = sinon.stub(); - instantiationService.stub(INotificationService, { prompt: target, _serviceBrand: null, notify: null, error: null, info: null, warn: null }); + instantiationService.stub(INotificationService, { prompt: target, _serviceBrand: null, notify: null!, error: null!, info: null!, warn: null! }); return testObject.writeConfiguration(ConfigurationTarget.USER, { key: 'configurationEditing.service.testSetting', value: 'value' }, { donotNotifyError: true }) .then(() => assert.fail('Should fail with ERROR_CONFIGURATION_FILE_DIRTY error.'), (error: ConfigurationEditingError) => { diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts index 3d34e15f1656f..d3920ed67bdc3 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts @@ -293,7 +293,7 @@ suite('WorkspaceContextService - Workspace', () => { done(); }); const workspace = { folders: [{ path: folders[0].uri.fsPath }, { path: folders[1].uri.fsPath }] }; - fs.writeFileSync(testObject.getWorkspace().configuration.fsPath, JSON.stringify(workspace, null, '\t')); + fs.writeFileSync(testObject.getWorkspace().configuration!.fsPath, JSON.stringify(workspace, null, '\t')); }, done); }); @@ -350,7 +350,7 @@ suite('WorkspaceContextService - Workspace', () => { const target = sinon.spy(); testObject.onDidChangeWorkspaceFolders(target); const workspace = { folders: [{ path: testObject.getWorkspace().folders[1].uri.fsPath }, { path: testObject.getWorkspace().folders[0].uri.fsPath }] }; - fs.writeFileSync(testObject.getWorkspace().configuration.fsPath, JSON.stringify(workspace, null, '\t')); + fs.writeFileSync(testObject.getWorkspace().configuration!.fsPath, JSON.stringify(workspace, null, '\t')); return testObject.reloadConfiguration() .then(() => { assert.equal(target.callCount, 1, `Should be called only once but called ${target.callCount} times`); @@ -365,7 +365,7 @@ suite('WorkspaceContextService - Workspace', () => { const target = sinon.spy(); testObject.onDidChangeWorkspaceFolders(target); const workspace = { folders: [{ path: testObject.getWorkspace().folders[0].uri.fsPath, name: '1' }, { path: testObject.getWorkspace().folders[1].uri.fsPath }] }; - fs.writeFileSync(testObject.getWorkspace().configuration.fsPath, JSON.stringify(workspace, null, '\t')); + fs.writeFileSync(testObject.getWorkspace().configuration!.fsPath, JSON.stringify(workspace, null, '\t')); return testObject.reloadConfiguration() .then(() => { assert.equal(target.callCount, 1, `Should be called only once but called ${target.callCount} times`); @@ -977,14 +977,14 @@ suite('WorkspaceConfigurationService-Multiroot', () => { test('application settings are not read from workspace', () => { fs.writeFileSync(environmentService.appSettingsPath, '{ "configurationService.workspace.applicationSetting": "userValue" }'); - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'settings', value: { 'configurationService.workspace.applicationSetting': 'workspaceValue' } }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'settings', value: { 'configurationService.workspace.applicationSetting': 'workspaceValue' } }, true) .then(() => testObject.reloadConfiguration()) .then(() => assert.equal(testObject.getValue('configurationService.workspace.applicationSetting'), 'userValue')); }); test('workspace settings override user settings after defaults are registered ', () => { fs.writeFileSync(environmentService.appSettingsPath, '{ "configurationService.workspace.newSetting": "userValue" }'); - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'settings', value: { 'configurationService.workspace.newSetting': 'workspaceValue' } }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'settings', value: { 'configurationService.workspace.newSetting': 'workspaceValue' } }, true) .then(() => testObject.reloadConfiguration()) .then(() => { configurationRegistry.registerConfiguration({ @@ -1030,7 +1030,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { test('resource setting in folder is read after it is registered later', () => { fs.writeFileSync(workspaceContextService.getWorkspace().folders[0].toResource('.vscode/settings.json').fsPath, '{ "configurationService.workspace.testNewResourceSetting2": "workspaceFolderValue" }'); - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'settings', value: { 'configurationService.workspace.testNewResourceSetting2': 'workspaceValue' } }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'settings', value: { 'configurationService.workspace.testNewResourceSetting2': 'workspaceValue' } }, true) .then(() => testObject.reloadConfiguration()) .then(() => { configurationRegistry.registerConfiguration({ @@ -1073,7 +1073,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { assert.equal(actual.workspaceFolder, void 0); assert.equal(actual.value, 'userValue'); - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'settings', value: { 'configurationService.workspace.testResourceSetting': 'workspaceValue' } }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'settings', value: { 'configurationService.workspace.testResourceSetting': 'workspaceValue' } }, true) .then(() => testObject.reloadConfiguration()) .then(() => { actual = testObject.inspect('configurationService.workspace.testResourceSetting'); @@ -1115,7 +1115,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { } ] }; - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'launch', value: expectedLaunchConfiguration }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'launch', value: expectedLaunchConfiguration }, true) .then(() => testObject.reloadConfiguration()) .then(() => { const actual = testObject.getValue('launch'); @@ -1140,7 +1140,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { } ] }; - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'launch', value: expectedLaunchConfiguration }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'launch', value: expectedLaunchConfiguration }, true) .then(() => testObject.reloadConfiguration()) .then(() => { const actual = testObject.inspect('launch').workspace; @@ -1221,7 +1221,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { }); test('task configurations are not read from workspace', () => { - return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'tasks', value: { 'version': '1.0' } }, true) + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'tasks', value: { 'version': '1.0' } }, true) .then(() => testObject.reloadConfiguration()) .then(() => { const actual = testObject.inspect('tasks.version'); diff --git a/src/vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts b/src/vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts index 180de3e850eff..43ac686e8bbd4 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts @@ -16,7 +16,7 @@ import { Delayer } from 'vs/base/common/async'; import { IRawFileChange } from 'vs/workbench/services/files/node/watcher/common'; import { FileChangeType } from 'vs/platform/files/common/files'; -function newRequest(basePath: string, ignored = []): IWatcherRequest { +function newRequest(basePath: string, ignored: string[] = []): IWatcherRequest { return { basePath, ignored }; } @@ -127,7 +127,7 @@ suite.skip('Chockidar watching', () => { const service = new ChokidarWatcherService(); const result: IRawFileChange[] = []; - let error = null; + let error: string | null = null; suiteSetup(async () => { await pfs.mkdirp(testDir); diff --git a/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts b/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts index 9807f419e5dc4..597621ee31a45 100644 --- a/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts +++ b/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts @@ -58,7 +58,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.CREATE); - assert.equal(event.target.resource.fsPath, resource.fsPath); + assert.equal(event.target!.resource.fsPath, resource.fsPath); toDispose.dispose(); }); }); @@ -93,7 +93,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.CREATE); - assert.equal(event.target.resource.fsPath, resource.fsPath); + assert.equal(event.target!.resource.fsPath, resource.fsPath); toDispose.dispose(); }); }); @@ -114,8 +114,8 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.CREATE); - assert.equal(event.target.resource.fsPath, resource.fsPath); - assert.equal(event.target.isDirectory, true); + assert.equal(event.target!.resource.fsPath, resource.fsPath); + assert.equal(event.target!.isDirectory, true); toDispose.dispose(); }); }); @@ -139,8 +139,8 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.CREATE); - assert.equal(event.target.resource.fsPath, resource.fsPath); - assert.equal(event.target.isDirectory, true); + assert.equal(event.target!.resource.fsPath, resource.fsPath); + assert.equal(event.target!.isDirectory, true); toDispose.dispose(); }); }); @@ -161,7 +161,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -185,7 +185,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -206,7 +206,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -230,7 +230,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -250,7 +250,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -271,7 +271,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -324,7 +324,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, resource.fsPath); assert.equal(event.operation, FileOperation.MOVE); - assert.equal(event.target.resource.fsPath, renamed.resource.fsPath); + assert.equal(event.target!.resource.fsPath, renamed.resource.fsPath); toDispose.dispose(); }); }); @@ -357,7 +357,7 @@ suite('FileService', () => { assert.ok(moveEvent); assert.equal(moveEvent.resource.fsPath, resource.fsPath); - assert.equal(moveEvent.target.resource.fsPath, moved.resource.fsPath); + assert.equal(moveEvent!.target!.resource.fsPath, moved.resource.fsPath); assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath); @@ -382,7 +382,7 @@ suite('FileService', () => { assert.ok(event); assert.equal(event.resource.fsPath, source.resource.fsPath); assert.equal(event.operation, FileOperation.COPY); - assert.equal(event.target.resource.fsPath, copied.resource.fsPath); + assert.equal(event.target!.resource.fsPath, copied.resource.fsPath); toDispose.dispose(); }); }); @@ -415,7 +415,7 @@ suite('FileService', () => { assert.ok(copyEvent); assert.equal(copyEvent.resource.fsPath, resource.fsPath); - assert.equal(copyEvent.target.resource.fsPath, copied.resource.fsPath); + assert.equal(copyEvent.target!.resource.fsPath, copied.resource.fsPath); assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath); @@ -505,10 +505,10 @@ suite('FileService', () => { test('resolveFile', () => { return service.resolveFile(uri.file(testDir), { resolveTo: [uri.file(path.join(testDir, 'deep'))] }).then(r => { - assert.equal(r.children.length, 8); + assert.equal(r.children!.length, 8); - const deep = utils.getByName(r, 'deep'); - assert.equal(deep.children.length, 4); + const deep = utils.getByName(r, 'deep')!; + assert.equal(deep.children!.length, 4); }); }); @@ -519,13 +519,13 @@ suite('FileService', () => { ]).then(res => { const r1 = res[0].stat; - assert.equal(r1.children.length, 8); + assert.equal(r1.children!.length, 8); - const deep = utils.getByName(r1, 'deep'); - assert.equal(deep.children.length, 4); + const deep = utils.getByName(r1, 'deep')!; + assert.equal(deep.children!.length, 4); const r2 = res[1].stat; - assert.equal(r2.children.length, 4); + assert.equal(r2.children!.length, 4); assert.equal(r2.name, 'deep'); }); }); diff --git a/src/vs/workbench/services/group/test/browser/editorGroupsService.test.ts b/src/vs/workbench/services/group/test/browser/editorGroupsService.test.ts index 173e001cdec3c..1fbe4a573c1a9 100644 --- a/src/vs/workbench/services/group/test/browser/editorGroupsService.test.ts +++ b/src/vs/workbench/services/group/test/browser/editorGroupsService.test.ts @@ -45,7 +45,7 @@ export class TestEditorInput extends EditorInput implements IFileEditorInput { resolve(): Promise { return Promise.resolve(); } matches(other: TestEditorInput): boolean { return other && this.resource.toString() === other.resource.toString() && other instanceof TestEditorInput; } setEncoding(encoding: string) { } - getEncoding(): string { return null; } + getEncoding(): string { return null!; } setPreferredEncoding(encoding: string) { } getResource(): URI { return this.resource; } setForceOpenAsBinary(): void { } @@ -225,12 +225,12 @@ suite('Editor groups service', () => { assert.equal(mru[0], rightGroup); assert.equal(mru[1], rootGroup); - let rightGroupInstantiator: IInstantiationService; + let rightGroupInstantiator!: IInstantiationService; part.activeGroup.invokeWithinContext(accessor => { rightGroupInstantiator = accessor.get(IInstantiationService); }); - let rootGroupInstantiator: IInstantiationService; + let rootGroupInstantiator!: IInstantiationService; rootGroup.invokeWithinContext(accessor => { rootGroupInstantiator = accessor.get(IInstantiationService); }); @@ -353,8 +353,8 @@ suite('Editor groups service', () => { test('options', () => { const part = createPart(); - let oldOptions: IEditorPartOptions; - let newOptions: IEditorPartOptions; + let oldOptions!: IEditorPartOptions; + let newOptions!: IEditorPartOptions; part.onDidEditorPartOptionsChange(event => { oldOptions = event.oldPartOptions; newOptions = event.newPartOptions; diff --git a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts index 75dc0ad53da1d..1b07bf6077630 100644 --- a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts @@ -115,7 +115,7 @@ suite('KeybindingsEditing', () => { } else { c(void 0); } - }).then(() => testDir = null); + }).then(() => testDir = null!); }); test('errors cases - parse errors', () => { @@ -247,7 +247,7 @@ suite('KeybindingsEditing', () => { function aResolvedKeybindingItem({ command, when, isDefault, firstPart, chordPart }: { command?: string, when?: string, isDefault?: boolean, firstPart?: { keyCode: KeyCode, modifiers?: Modifiers }, chordPart?: { keyCode: KeyCode, modifiers?: Modifiers } }): ResolvedKeybindingItem { const aSimpleKeybinding = function (part: { keyCode: KeyCode, modifiers?: Modifiers }): SimpleKeybinding { const { ctrlKey, shiftKey, altKey, metaKey } = part.modifiers || { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false }; - return new SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, part.keyCode); + return new SimpleKeybinding(ctrlKey!, shiftKey!, altKey!, metaKey!, part.keyCode); }; const keybinding = firstPart ? chordPart ? new ChordKeybinding(aSimpleKeybinding(firstPart), aSimpleKeybinding(chordPart)) : aSimpleKeybinding(firstPart) : null; return new ResolvedKeybindingItem(keybinding ? new USLayoutResolvedKeybinding(keybinding, OS) : null, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === void 0 ? true : isDefault); diff --git a/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts b/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts index 0e0c5c7beada3..19b5cef5e04a9 100644 --- a/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts +++ b/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts @@ -37,7 +37,7 @@ suite('keyboardMapper - MAC de_ch', () => { } function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh)!, expected); } test('kb => hw', () => { @@ -463,7 +463,7 @@ suite('keyboardMapper - LINUX de_ch', () => { } function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected); } test('kb => hw', () => { @@ -808,7 +808,7 @@ suite('keyboardMapper - LINUX en_us', () => { }); function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected); } test('resolveKeybinding Ctrl+A', () => { @@ -1251,7 +1251,7 @@ suite('keyboardMapper', () => { assertNumpadKeyboardEvent(KeyCode.DownArrow, 'Numpad2', 'DownArrow', 'Down', 'down', '[ArrowDown]'); assertNumpadKeyboardEvent(KeyCode.PageDown, 'Numpad3', 'PageDown', 'PageDown', 'pagedown', '[PageDown]'); assertNumpadKeyboardEvent(KeyCode.LeftArrow, 'Numpad4', 'LeftArrow', 'Left', 'left', '[ArrowLeft]'); - assertNumpadKeyboardEvent(KeyCode.Unknown, 'Numpad5', 'NumPad5', null, 'numpad5', '[Numpad5]'); + assertNumpadKeyboardEvent(KeyCode.Unknown, 'Numpad5', 'NumPad5', null!, 'numpad5', '[Numpad5]'); assertNumpadKeyboardEvent(KeyCode.RightArrow, 'Numpad6', 'RightArrow', 'Right', 'right', '[ArrowRight]'); assertNumpadKeyboardEvent(KeyCode.Home, 'Numpad7', 'Home', 'Home', 'home', '[Home]'); assertNumpadKeyboardEvent(KeyCode.UpArrow, 'Numpad8', 'UpArrow', 'Up', 'up', '[ArrowUp]'); @@ -1326,7 +1326,7 @@ suite('keyboardMapper - LINUX ru', () => { }); function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected); } test('resolveKeybinding Ctrl+S', () => { @@ -1396,7 +1396,7 @@ suite('keyboardMapper - MAC zh_hant', () => { }); function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh)!, expected); } test('issue #28237 resolveKeybinding Cmd+C', () => { @@ -1427,7 +1427,7 @@ function _assertKeybindingTranslation(mapper: MacLinuxKeyboardMapper, OS: Operat const runtimeKeybinding = createKeybinding(kb, OS); - const keybindingLabel = new USLayoutResolvedKeybinding(runtimeKeybinding, OS).getUserSettingsLabel(); + const keybindingLabel = new USLayoutResolvedKeybinding(runtimeKeybinding!, OS).getUserSettingsLabel(); const actualHardwareKeypresses = mapper.simpleKeybindingToScanCodeBinding(runtimeKeybinding); if (actualHardwareKeypresses.length === 0) { diff --git a/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts b/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts index 658777f142872..cf17bb6de9b96 100644 --- a/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts +++ b/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts @@ -106,8 +106,8 @@ suite('KeybindingsEditorModel test', () => { aResolvedKeybindingItem({ command: 'd' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }) ); - registerCommandWithTitle(keybindings[1].command, 'B Title'); - registerCommandWithTitle(keybindings[3].command, 'A Title'); + registerCommandWithTitle(keybindings[1].command!, 'B Title'); + registerCommandWithTitle(keybindings[3].command!, 'A Title'); const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]]; instantiationService.stub(IKeybindingService, 'getKeybindings', () => keybindings); @@ -127,8 +127,8 @@ suite('KeybindingsEditorModel test', () => { aResolvedKeybindingItem({ command: sameId, firstPart: { keyCode: KeyCode.Escape }, isDefault: false }) ); - registerCommandWithTitle(keybindings[1].command, 'Same Title'); - registerCommandWithTitle(keybindings[3].command, 'Same Title'); + registerCommandWithTitle(keybindings[1].command!, 'Same Title'); + registerCommandWithTitle(keybindings[3].command!, 'Same Title'); const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]]; await testObject.resolve({}); @@ -157,22 +157,22 @@ suite('KeybindingsEditorModel test', () => { assert.equal(actual.keybindingItem.command, expected.command); assert.equal(actual.keybindingItem.commandLabel, ''); assert.equal(actual.keybindingItem.commandDefaultLabel, null); - assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel()); - assert.equal(actual.keybindingItem.when, expected.when.serialize()); + assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding!.getAriaLabel()); + assert.equal(actual.keybindingItem.when, expected.when!.serialize()); }); test('convert keybinding with title to entry', async () => { const expected = aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' }); prepareKeybindingService(expected); - registerCommandWithTitle(expected.command, 'Some Title'); + registerCommandWithTitle(expected.command!, 'Some Title'); await testObject.resolve({}); const actual = testObject.fetch('')[0]; assert.equal(actual.keybindingItem.command, expected.command); assert.equal(actual.keybindingItem.commandLabel, 'Some Title'); assert.equal(actual.keybindingItem.commandDefaultLabel, null); - assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel()); - assert.equal(actual.keybindingItem.when, expected.when.serialize()); + assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding!.getAriaLabel()); + assert.equal(actual.keybindingItem.when, expected.when!.serialize()); }); test('convert without title and binding to entry', async () => { @@ -282,8 +282,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('cmd').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by meta key', async () => { @@ -296,8 +296,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('meta').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by command key', async () => { @@ -310,8 +310,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('command').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by windows key', async () => { @@ -324,8 +324,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('windows').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by alt key', async () => { @@ -336,8 +336,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('alt').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by option key', async () => { @@ -348,8 +348,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('option').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by ctrl key', async () => { @@ -360,8 +360,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('ctrl').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by control key', async () => { @@ -372,8 +372,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('control').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by shift key', async () => { @@ -384,8 +384,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('shift').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by arrow', async () => { @@ -396,8 +396,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('arrow').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by modifier and key', async () => { @@ -408,8 +408,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('alt right').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by key and modifier', async () => { @@ -431,8 +431,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('alt cmd esc').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { altKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by modifiers in random order and key', async () => { @@ -444,8 +444,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter by first part', async () => { @@ -457,8 +457,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter matches in chord part', async () => { @@ -470,8 +470,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('cmd del').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, { keyCode: true }); }); test('filter matches first part and in chord part', async () => { @@ -483,8 +483,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('cmd shift esc del').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, { keyCode: true }); }); test('filter exact matches', async () => { @@ -495,8 +495,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('"ctrl c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter exact matches with first and chord part', async () => { @@ -507,8 +507,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('"shift meta escape ctrl c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { ctrlKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, { ctrlKey: true, keyCode: true }); }); test('filter exact matches with first and chord part no results', async () => { @@ -530,8 +530,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('"control+c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { ctrlKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, {}); }); test('filter matches with + separator in first and chord parts', async () => { @@ -542,8 +542,8 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('"shift+meta+escape ctrl+c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true, ctrlKey: true }); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.chordPart, { keyCode: true, ctrlKey: true }); }); test('filter exact matches with space #32993', async () => { @@ -565,7 +565,7 @@ suite('KeybindingsEditorModel test', () => { await testObject.resolve({}); const actual = testObject.fetch('"down"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches!.firstPart, { keyCode: true }); }); function prepareKeybindingService(...keybindingItems: ResolvedKeybindingItem[]): ResolvedKeybindingItem[] { @@ -591,7 +591,7 @@ suite('KeybindingsEditorModel test', () => { assert.equal(actual.command, expected.command); if (actual.when) { assert.ok(!!expected.when); - assert.equal(actual.when.serialize(), expected.when.serialize()); + assert.equal(actual.when.serialize(), expected.when!.serialize()); } else { assert.ok(!expected.when); } @@ -599,7 +599,7 @@ suite('KeybindingsEditorModel test', () => { if (actual.resolvedKeybinding) { assert.ok(!!expected.resolvedKeybinding); - assert.equal(actual.resolvedKeybinding.getLabel(), expected.resolvedKeybinding.getLabel()); + assert.equal(actual.resolvedKeybinding.getLabel(), expected.resolvedKeybinding!.getLabel()); } else { assert.ok(!expected.resolvedKeybinding); } @@ -608,7 +608,7 @@ suite('KeybindingsEditorModel test', () => { function aResolvedKeybindingItem({ command, when, isDefault, firstPart, chordPart }: { command?: string, when?: string, isDefault?: boolean, firstPart?: { keyCode: KeyCode, modifiers?: Modifiers }, chordPart?: { keyCode: KeyCode, modifiers?: Modifiers } }): ResolvedKeybindingItem { const aSimpleKeybinding = function (part: { keyCode: KeyCode, modifiers?: Modifiers }): SimpleKeybinding { const { ctrlKey, shiftKey, altKey, metaKey } = part.modifiers || { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false }; - return new SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, part.keyCode); + return new SimpleKeybinding(ctrlKey!, shiftKey!, altKey!, metaKey!, part.keyCode); }; const keybinding = firstPart ? chordPart ? new ChordKeybinding(aSimpleKeybinding(firstPart), aSimpleKeybinding(chordPart)) : aSimpleKeybinding(firstPart) : null; return new ResolvedKeybindingItem(keybinding ? new USLayoutResolvedKeybinding(keybinding, OS) : null, command || 'some command', null, when ? ContextKeyExpr.deserialize(when) : null, isDefault === void 0 ? true : isDefault); diff --git a/src/vs/workbench/services/preferences/test/common/preferencesModel.test.ts b/src/vs/workbench/services/preferences/test/common/preferencesModel.test.ts index 8550a177cf4b2..d4dae17cbc34b 100644 --- a/src/vs/workbench/services/preferences/test/common/preferencesModel.test.ts +++ b/src/vs/workbench/services/preferences/test/common/preferencesModel.test.ts @@ -13,7 +13,7 @@ suite('Preferences Model test', () => { private validator: (value: any) => string; constructor(private settings: IConfigurationPropertySchema) { - this.validator = createValidator(settings); + this.validator = createValidator(settings)!; } public accepts(input) { diff --git a/src/vs/workbench/services/progress/test/progressService.test.ts b/src/vs/workbench/services/progress/test/progressService.test.ts index ae98bbd35af95..2f1e0fbf61115 100644 --- a/src/vs/workbench/services/progress/test/progressService.test.ts +++ b/src/vs/workbench/services/progress/test/progressService.test.ts @@ -29,8 +29,8 @@ class TestViewletService implements IViewletService { onDidViewletClose = this.onDidViewletCloseEmitter.event; onDidViewletEnablementChange = this.onDidViewletEnableEmitter.event; - public openViewlet(id: string, focus?: boolean): Promise { - return Promise.resolve(null); + public openViewlet(id: string, focus?: boolean): Promise { + return Promise.resolve(null!); } public getViewlets(): ViewletDescriptor[] { @@ -54,11 +54,11 @@ class TestViewletService implements IViewletService { } public getViewlet(id: string): ViewletDescriptor { - return null; + return null!; } public getProgressIndicator(id: string) { - return null; + return null!; } } @@ -69,7 +69,7 @@ class TestPanelService implements IPanelService { onDidPanelClose = new Emitter().event; public openPanel(id: string, focus?: boolean): IPanel { - return null; + return null!; } public getPanels(): any[] { @@ -130,14 +130,14 @@ class TestViewlet implements IViewlet { * Returns the action item for a specific action. */ getActionItem(action: IAction): IActionItem { - return null; + return null!; } /** * Returns the underlying control of this composite. */ getControl(): IEditorControl { - return null; + return null!; } /** @@ -176,14 +176,14 @@ class TestProgressBar { } public infinite() { - this.fDone = null; + this.fDone = null!; this.fInfinite = true; return this; } public total(total: number) { - this.fDone = null; + this.fDone = null!; this.fTotal = total; return this; @@ -194,7 +194,7 @@ class TestProgressBar { } public worked(worked: number) { - this.fDone = null; + this.fDone = null!; if (this.fWorked) { this.fWorked += worked; @@ -208,9 +208,9 @@ class TestProgressBar { public done() { this.fDone = true; - this.fInfinite = null; - this.fWorked = null; - this.fTotal = null; + this.fInfinite = null!; + this.fWorked = null!; + this.fTotal = null!; return this; } diff --git a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts index cf3b096d22197..2a2c687542f31 100644 --- a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts +++ b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts @@ -47,7 +47,7 @@ class TestSearchEngine implements ISearchEngine { (function next() { process.nextTick(() => { if (self.isCanceled) { - done(null, { + done(null!, { limitHit: false, stats: stats }); @@ -55,7 +55,7 @@ class TestSearchEngine implements ISearchEngine { } const result = self.result(); if (!result) { - done(null, { + done(null!, { limitHit: false, stats: stats }); @@ -109,7 +109,7 @@ suite('RawSearchService', () => { } }; - await service.doFileSearchWithEngine(Engine, rawSearch, cb, null, 0); + await service.doFileSearchWithEngine(Engine, rawSearch, cb, null!, 0); return assert.strictEqual(results, 5); }); @@ -119,7 +119,7 @@ suite('RawSearchService', () => { const Engine = TestSearchEngine.bind(null, () => i-- && rawMatch); const service = new RawSearchService(); - const results = []; + const results: number[] = []; const cb: (p: ISerializedSearchProgressItem) => void = value => { if (Array.isArray(value)) { value.forEach(m => { @@ -158,7 +158,7 @@ suite('RawSearchService', () => { return emitter.event; } - const progressResults = []; + const progressResults: any[] = []; const onProgress = match => { assert.strictEqual(match.resource.path, uriPath); progressResults.push(match); @@ -218,7 +218,7 @@ suite('RawSearchService', () => { const Engine = TestSearchEngine.bind(null, () => matches.shift()); const service = new RawSearchService(); - const results = []; + const results: any[] = []; const cb = value => { if (Array.isArray(value)) { results.push(...value.map(v => v.path)); @@ -234,7 +234,7 @@ suite('RawSearchService', () => { sortByScore: true, maxResults: 2 }, cb, undefined, 1); - assert.notStrictEqual(typeof TestSearchEngine.last.config.maxResults, 'number'); + assert.notStrictEqual(typeof TestSearchEngine.last.config!.maxResults, 'number'); assert.deepStrictEqual(results, [path.normalize('/some/where/bbc'), path.normalize('/some/where/bab')]); }); @@ -244,7 +244,7 @@ suite('RawSearchService', () => { const Engine = TestSearchEngine.bind(null, () => i-- && rawMatch); const service = new RawSearchService(); - const results = []; + const results: number[] = []; const cb = value => { if (Array.isArray(value)) { value.forEach(m => { @@ -277,7 +277,7 @@ suite('RawSearchService', () => { const Engine = TestSearchEngine.bind(null, () => matches.shift()); const service = new RawSearchService(); - const results = []; + const results: any[] = []; const cb = value => { if (Array.isArray(value)) { results.push(...value.map(v => v.path)); @@ -295,7 +295,7 @@ suite('RawSearchService', () => { assert.strictEqual((complete.stats).fromCache, false); assert.deepStrictEqual(results, [path.normalize('/some/where/bcb'), path.normalize('/some/where/bbc'), path.normalize('/some/where/aab')]); }).then(async () => { - const results = []; + const results: any[] = []; const cb = value => { if (Array.isArray(value)) { results.push(...value.map(v => v.path)); @@ -324,7 +324,7 @@ suite('RawSearchService', () => { basename: 'bc', size: 3 }); - const results = []; + const results: any[] = []; const cb = value => { if (Array.isArray(value)) { results.push(...value.map(v => v.path)); diff --git a/src/vs/workbench/services/search/test/node/search.test.ts b/src/vs/workbench/services/search/test/node/search.test.ts index 1c32b06c8a685..9bc9f8436b5f5 100644 --- a/src/vs/workbench/services/search/test/node/search.test.ts +++ b/src/vs/workbench/services/search/test/node/search.test.ts @@ -779,8 +779,8 @@ suite('FileWalker', () => { const cmd1 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.notStrictEqual(stdout1.split('\n').indexOf(file1), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file1), -1, stdout1); const walker = new FileWalker({ type: QueryType.File, @@ -790,8 +790,8 @@ suite('FileWalker', () => { const cmd2 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd2, 'utf8', /*isRipgrep=*/false, (err2, stdout2) => { assert.equal(err2, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.strictEqual(stdout2.split('\n').indexOf(file1), -1, stdout2); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.strictEqual(stdout2!.split('\n').indexOf(file1), -1, stdout2); done(); }); }); @@ -818,8 +818,8 @@ suite('FileWalker', () => { const cmd1 = walker.spawnFindCmd(folderQueries[0]); walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); - assert(outputContains(stdout1, file0), stdout1); - assert(!outputContains(stdout1, file1), stdout1); + assert(outputContains(stdout1!, file0), stdout1); + assert(!outputContains(stdout1!, file1), stdout1); done(); }); }); @@ -839,17 +839,17 @@ suite('FileWalker', () => { const cmd1 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.notStrictEqual(stdout1.split('\n').indexOf(file1), -1, stdout1); - assert.notStrictEqual(stdout1.split('\n').indexOf(file2), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file1), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file2), -1, stdout1); const walker = new FileWalker({ type: QueryType.File, folderQueries: ROOT_FOLDER_QUERY, excludePattern: { '{**/examples,**/more}': true } }); const cmd2 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd2, 'utf8', /*isRipgrep=*/false, (err2, stdout2) => { assert.equal(err2, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.strictEqual(stdout2.split('\n').indexOf(file1), -1, stdout2); - assert.strictEqual(stdout2.split('\n').indexOf(file2), -1, stdout2); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.strictEqual(stdout2!.split('\n').indexOf(file1), -1, stdout2); + assert.strictEqual(stdout2!.split('\n').indexOf(file2), -1, stdout2); done(); }); }); @@ -869,15 +869,15 @@ suite('FileWalker', () => { const cmd1 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.notStrictEqual(stdout1.split('\n').indexOf(file1), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file1), -1, stdout1); const walker = new FileWalker({ type: QueryType.File, folderQueries: ROOT_FOLDER_QUERY, excludePattern: { '**/examples/subfolder': true } }); const cmd2 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd2, 'utf8', /*isRipgrep=*/false, (err2, stdout2) => { assert.equal(err2, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.strictEqual(stdout2.split('\n').indexOf(file1), -1, stdout2); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.strictEqual(stdout2!.split('\n').indexOf(file1), -1, stdout2); done(); }); }); @@ -897,15 +897,15 @@ suite('FileWalker', () => { const cmd1 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.notStrictEqual(stdout1.split('\n').indexOf(file1), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file1), -1, stdout1); const walker = new FileWalker({ type: QueryType.File, folderQueries: ROOT_FOLDER_QUERY, excludePattern: { '**/subfolder/anotherfolder': true } }); const cmd2 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd2, 'utf8', /*isRipgrep=*/false, (err2, stdout2) => { assert.equal(err2, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.strictEqual(stdout2.split('\n').indexOf(file1), -1, stdout2); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.strictEqual(stdout2!.split('\n').indexOf(file1), -1, stdout2); done(); }); }); @@ -925,15 +925,15 @@ suite('FileWalker', () => { const cmd1 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.notStrictEqual(stdout1.split('\n').indexOf(file1), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file1), -1, stdout1); const walker = new FileWalker({ type: QueryType.File, folderQueries: ROOT_FOLDER_QUERY, excludePattern: { 'examples/subfolder': true } }); const cmd2 = walker.spawnFindCmd(TEST_ROOT_FOLDER); walker.readStdout(cmd2, 'utf8', /*isRipgrep=*/false, (err2, stdout2) => { assert.equal(err2, null); - assert.notStrictEqual(stdout1.split('\n').indexOf(file0), -1, stdout1); - assert.strictEqual(stdout2.split('\n').indexOf(file1), -1, stdout2); + assert.notStrictEqual(stdout1!.split('\n').indexOf(file0), -1, stdout1); + assert.strictEqual(stdout2!.split('\n').indexOf(file1), -1, stdout2); done(); }); }); @@ -970,10 +970,10 @@ suite('FileWalker', () => { walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => { assert.equal(err1, null); for (const fileIn of filesIn) { - assert.notStrictEqual(stdout1.split('\n').indexOf(fileIn), -1, stdout1); + assert.notStrictEqual(stdout1!.split('\n').indexOf(fileIn), -1, stdout1); } for (const fileOut of filesOut) { - assert.strictEqual(stdout1.split('\n').indexOf(fileOut), -1, stdout1); + assert.strictEqual(stdout1!.split('\n').indexOf(fileOut), -1, stdout1); } done(); }); diff --git a/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts b/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts index f4edf8a3bff6e..2493f8ee852d6 100644 --- a/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts +++ b/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts @@ -15,7 +15,7 @@ import { ISerializedFileMatch } from 'vs/workbench/services/search/node/search'; import { TextSearchEngineAdapter } from 'vs/workbench/services/search/node/textSearchAdapter'; function countAll(matches: ISerializedFileMatch[]): number { - return matches.reduce((acc, m) => acc + m.numMatches, 0); + return matches.reduce((acc, m) => acc + m.numMatches!, 0); } const TEST_FIXTURES = path.normalize(getPathFromAmdModule(require, './fixtures')); @@ -39,7 +39,7 @@ function doLegacySearchTest(config: ITextQuery, expectedResultCount: number | Fu if (result && Array.isArray(result)) { c += countAll(result); } - }, null).then(() => { + }, null!).then(() => { if (typeof expectedResultCount === 'function') { assert(expectedResultCount(c)); } else { @@ -55,7 +55,7 @@ function doRipgrepSearchTest(query: ITextQuery, expectedResultCount: number | Fu const results: ISerializedFileMatch[] = []; return engine.search(new CancellationTokenSource().token, _results => { if (_results) { - c += _results.reduce((acc, cur) => acc + cur.numMatches, 0); + c += _results.reduce((acc, cur) => acc + cur.numMatches!, 0); results.push(..._results); } }, () => { }).then(() => { @@ -319,7 +319,7 @@ suite('Search-integration', function () { }; return doRipgrepSearchTest(config, 1).then(results => { - const matchRange = (results[0].results[0]).ranges; + const matchRange = (results[0].results![0]).ranges; assert.deepEqual(matchRange, [{ startLineNumber: 0, startColumn: 1, @@ -338,8 +338,8 @@ suite('Search-integration', function () { return doRipgrepSearchTest(config, 15).then(results => { assert.equal(results.length, 3); - assert.equal(results[0].results.length, 1); - const match = results[0].results[0]; + assert.equal(results[0].results!.length, 1); + const match = results[0].results![0]; assert.equal((match.ranges).length, 5); }); }); @@ -355,13 +355,13 @@ suite('Search-integration', function () { return doRipgrepSearchTest(config, 4).then(results => { assert.equal(results.length, 4); - assert.equal((results[0].results[0]).lineNumber, 25); - assert.equal((results[0].results[0]).text, ' compiler.addUnit(prog,"input.ts");'); + assert.equal((results[0].results![0]).lineNumber, 25); + assert.equal((results[0].results![0]).text, ' compiler.addUnit(prog,"input.ts");'); // assert.equal((results[1].results[0]).preview.text, ' compiler.typeCheck();\n'); // See https://github.com/BurntSushi/ripgrep/issues/1095 - assert.equal((results[2].results[0]).lineNumber, 27); - assert.equal((results[2].results[0]).text, ' compiler.emit();'); - assert.equal((results[3].results[0]).lineNumber, 28); - assert.equal((results[3].results[0]).text, ''); + assert.equal((results[2].results![0]).lineNumber, 27); + assert.equal((results[2].results![0]).text, ' compiler.emit();'); + assert.equal((results[3].results![0]).lineNumber, 28); + assert.equal((results[3].results![0]).text, ''); }); }); diff --git a/src/vs/workbench/services/textfile/test/textFileService.test.ts b/src/vs/workbench/services/textfile/test/textFileService.test.ts index 1dfdc4bdcc2e8..f5222c90e32ad 100644 --- a/src/vs/workbench/services/textfile/test/textFileService.test.ts +++ b/src/vs/workbench/services/textfile/test/textFileService.test.ts @@ -219,9 +219,9 @@ suite('Files - TextFileService', () => { assert.equal(res.results.length, 1); assert.ok(res.results[0].success); - assert.equal(res.results[0].target.scheme, Schemas.file); - assert.equal(res.results[0].target.authority, untitledUncUri.authority); - assert.equal(res.results[0].target.path, untitledUncUri.path); + assert.equal(res.results[0].target!.scheme, Schemas.file); + assert.equal(res.results[0].target!.authority, untitledUncUri.authority); + assert.equal(res.results[0].target!.path, untitledUncUri.path); }); }); }); diff --git a/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts b/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts index 0ddaa02741bf3..81e418976591f 100644 --- a/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts +++ b/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts @@ -47,7 +47,7 @@ suite('Workbench - TextModelResolverService', () => { teardown(() => { if (model) { model.dispose(); - model = void 0; + model = (void 0)!; } (accessor.textFileService.models).clear(); (accessor.textFileService.models).dispose(); @@ -63,11 +63,11 @@ suite('Workbench - TextModelResolverService', () => { return Promise.resolve(accessor.modelService.createModel(modelContent, languageSelection, resource)); } - return Promise.resolve(null); + return Promise.resolve(null!); } }); - let resource = URI.from({ scheme: 'test', authority: null, path: 'thePath' }); + let resource = URI.from({ scheme: 'test', authority: null!, path: 'thePath' }); let input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource); return input.resolve().then(async model => { @@ -132,7 +132,7 @@ suite('Workbench - TextModelResolverService', () => { }); test('even loading documents should be refcounted', async () => { - let resolveModel: Function; + let resolveModel!: Function; let waitForIt = new Promise(c => resolveModel = c); const disposable = accessor.textModelResolverService.registerTextModelContentProvider('test', { @@ -145,7 +145,7 @@ suite('Workbench - TextModelResolverService', () => { } }); - const uri = URI.from({ scheme: 'test', authority: null, path: 'thePath' }); + const uri = URI.from({ scheme: 'test', authority: null!, path: 'thePath' }); const modelRefPromise1 = accessor.textModelResolverService.createModelReference(uri); const modelRefPromise2 = accessor.textModelResolverService.createModelReference(uri); diff --git a/src/vs/workbench/test/browser/part.test.ts b/src/vs/workbench/test/browser/part.test.ts index c94fb997d5f8b..c1aae31346ae9 100644 --- a/src/vs/workbench/test/browser/part.test.ts +++ b/src/vs/workbench/test/browser/part.test.ts @@ -19,12 +19,12 @@ class MyPart extends Part { createTitleArea(parent: HTMLElement): HTMLElement { assert.strictEqual(parent, this.expectedParent); - return super.createTitleArea(parent); + return super.createTitleArea(parent)!; } createContentArea(parent: HTMLElement): HTMLElement { assert.strictEqual(parent, this.expectedParent); - return super.createContentArea(parent); + return super.createContentArea(parent)!; } getMemento(scope: StorageScope) { @@ -68,7 +68,7 @@ class MyPart3 extends Part { } createTitleArea(parent: HTMLElement): HTMLElement { - return null; + return null!; } createContentArea(parent: HTMLElement): HTMLElement { @@ -97,7 +97,7 @@ suite('Workbench parts', () => { test('Creation', () => { let b = document.createElement('div'); - document.getElementById(fixtureId).appendChild(b); + document.getElementById(fixtureId)!.appendChild(b); hide(b); let part = new MyPart(b); @@ -134,7 +134,7 @@ suite('Workbench parts', () => { test('Part Layout with Title and Content', function () { let b = document.createElement('div'); - document.getElementById(fixtureId).appendChild(b); + document.getElementById(fixtureId)!.appendChild(b); hide(b); let part = new MyPart2(); @@ -146,7 +146,7 @@ suite('Workbench parts', () => { test('Part Layout with Content only', function () { let b = document.createElement('div'); - document.getElementById(fixtureId).appendChild(b); + document.getElementById(fixtureId)!.appendChild(b); hide(b); let part = new MyPart3(); diff --git a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts index 98dc31ccfe49a..5c6f6e9e13b8a 100644 --- a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts @@ -267,7 +267,7 @@ suite('Workbench base editor', () => { super(); } public getTypeId() { return 'testEditorInput'; } - public resolve(): Promise { return Promise.resolve(null); } + public resolve(): Promise { return Promise.resolve(null!); } public matches(other: TestEditorInput): boolean { return other && this.id === other.id && other instanceof TestEditorInput; diff --git a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts index 4fdcb2b7cef45..22b8c35cbce62 100644 --- a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts @@ -40,7 +40,7 @@ suite('Editor - Range decorations', () => { model = aModel(URI.file('some_file')); codeEditor = createTestCodeEditor({ model: model }); - instantiationService.stub(IEditorService, 'activeEditor', { getResource: () => { return codeEditor.getModel().uri; } }); + instantiationService.stub(IEditorService, 'activeEditor', { getResource: () => { return codeEditor.getModel()!.uri; } }); instantiationService.stub(IEditorService, 'activeTextEditorWidget', codeEditor); testObject = instantiationService.createInstance(RangeHighlightDecorations); diff --git a/src/vs/workbench/test/browser/quickopen.test.ts b/src/vs/workbench/test/browser/quickopen.test.ts index 9e9cf9515a9bf..30b61a2633c88 100644 --- a/src/vs/workbench/test/browser/quickopen.test.ts +++ b/src/vs/workbench/test/browser/quickopen.test.ts @@ -13,9 +13,9 @@ import { QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpen export class TestQuickOpenService implements IQuickOpenService { public _serviceBrand: any; - private callback: (prefix: string) => void; + private callback?: (prefix?: string) => void; - constructor(callback?: (prefix: string) => void) { + constructor(callback?: (prefix?: string) => void) { this.callback = callback; } @@ -37,11 +37,11 @@ export class TestQuickOpenService implements IQuickOpenService { } get onShow(): Event { - return null; + return null!; } get onHide(): Event { - return null; + return null!; } public dispose() { } @@ -59,7 +59,7 @@ suite('QuickOpen', () => { 'testhandler', ',', 'Handler', - null + null! ); registry.registerQuickOpenHandler(handler); @@ -71,7 +71,7 @@ suite('QuickOpen', () => { }); test('QuickOpen Action', () => { - let defaultAction = new QuickOpenAction('id', 'label', void 0, new TestQuickOpenService((prefix: string) => assert(!prefix))); + let defaultAction = new QuickOpenAction('id', 'label', (void 0)!, new TestQuickOpenService((prefix: string) => assert(!prefix))); let prefixAction = new QuickOpenAction('id', 'label', ',', new TestQuickOpenService((prefix: string) => assert(!!prefix))); defaultAction.run(); diff --git a/src/vs/workbench/test/browser/viewlet.test.ts b/src/vs/workbench/test/browser/viewlet.test.ts index ed9c3a678dd85..6545d38ced2be 100644 --- a/src/vs/workbench/test/browser/viewlet.test.ts +++ b/src/vs/workbench/test/browser/viewlet.test.ts @@ -13,7 +13,7 @@ suite('Viewlets', () => { class TestViewlet extends Viewlet { constructor() { - super('id', null, null, null, null, null); + super('id', null!, null!, null!, null!, null!); } public layout(dimension: any): void { diff --git a/src/vs/workbench/test/common/editor/editorDiffModel.test.ts b/src/vs/workbench/test/common/editor/editorDiffModel.test.ts index 599f44c7bbc35..3023add68cab8 100644 --- a/src/vs/workbench/test/common/editor/editorDiffModel.test.ts +++ b/src/vs/workbench/test/common/editor/editorDiffModel.test.ts @@ -44,12 +44,12 @@ suite('Workbench editor model', () => { return Promise.resolve(accessor.modelService.createModel(modelContent, languageSelection, resource)); } - return Promise.resolve(null); + return Promise.resolve(null!); } }); - let input = instantiationService.createInstance(ResourceEditorInput, 'name', 'description', URI.from({ scheme: 'test', authority: null, path: 'thePath' })); - let otherInput = instantiationService.createInstance(ResourceEditorInput, 'name2', 'description', URI.from({ scheme: 'test', authority: null, path: 'thePath' })); + let input = instantiationService.createInstance(ResourceEditorInput, 'name', 'description', URI.from({ scheme: 'test', authority: null!, path: 'thePath' })); + let otherInput = instantiationService.createInstance(ResourceEditorInput, 'name2', 'description', URI.from({ scheme: 'test', authority: null!, path: 'thePath' })); let diffInput = new DiffEditorInput('name', 'description', input, otherInput); return diffInput.resolve().then((model: any) => { diff --git a/src/vs/workbench/test/common/editor/editorGroups.test.ts b/src/vs/workbench/test/common/editor/editorGroups.test.ts index bb4dccb4605cb..8ddb989641f40 100644 --- a/src/vs/workbench/test/common/editor/editorGroups.test.ts +++ b/src/vs/workbench/test/common/editor/editorGroups.test.ts @@ -77,7 +77,7 @@ class TestEditorInput extends EditorInput { super(); } getTypeId() { return 'testEditorInputForGroups'; } - resolve(): Promise { return Promise.resolve(null); } + resolve(): Promise { return Promise.resolve(null!); } matches(other: TestEditorInput): boolean { return other && this.id === other.id && other instanceof TestEditorInput; @@ -97,7 +97,7 @@ class NonSerializableTestEditorInput extends EditorInput { super(); } getTypeId() { return 'testEditorInputForGroups-nonSerializable'; } - resolve(): Promise { return Promise.resolve(null); } + resolve(): Promise { return Promise.resolve(null!); } matches(other: NonSerializableTestEditorInput): boolean { return other && this.id === other.id && other instanceof NonSerializableTestEditorInput; @@ -110,7 +110,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput { super(); } getTypeId() { return 'testFileEditorInputForGroups'; } - resolve(): Promise { return Promise.resolve(null); } + resolve(): Promise { return Promise.resolve(null!); } matches(other: TestFileEditorInput): boolean { return other && this.id === other.id && other instanceof TestFileEditorInput; @@ -120,7 +120,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput { } getEncoding(): string { - return null; + return null!; } setPreferredEncoding(encoding: string) { @@ -781,7 +781,7 @@ suite('Workbench editor groups', () => { group.openEditor(input5, { active: true, pinned: true }); // Close Others - group.closeEditors(group.activeEditor); + group.closeEditors(group.activeEditor!); assert.equal(group.activeEditor, input5); assert.equal(group.count, 1); @@ -795,7 +795,7 @@ suite('Workbench editor groups', () => { // Close Left assert.equal(group.activeEditor, input3); - group.closeEditors(group.activeEditor, CloseDirection.LEFT); + group.closeEditors(group.activeEditor!, CloseDirection.LEFT); assert.equal(group.activeEditor, input3); assert.equal(group.count, 3); assert.equal(group.getEditors()[0], input3); @@ -812,7 +812,7 @@ suite('Workbench editor groups', () => { // Close Right assert.equal(group.activeEditor, input3); - group.closeEditors(group.activeEditor, CloseDirection.RIGHT); + group.closeEditors(group.activeEditor!, CloseDirection.RIGHT); assert.equal(group.activeEditor, input3); assert.equal(group.count, 3); assert.equal(group.getEditors()[0], input1); @@ -953,16 +953,16 @@ suite('Workbench editor groups', () => { group.openEditor(input1); assert.equal(group.count, 1); - assert.equal(group.activeEditor.matches(input1), true); - assert.equal(group.previewEditor.matches(input1), true); + assert.equal(group.activeEditor!.matches(input1), true); + assert.equal(group.previewEditor!.matches(input1), true); assert.equal(group.isActive(input1), true); // Create model again - should load from storage group = inst.createInstance(EditorGroup, group.serialize()); assert.equal(group.count, 1); - assert.equal(group.activeEditor.matches(input1), true); - assert.equal(group.previewEditor.matches(input1), true); + assert.equal(group.activeEditor!.matches(input1), true); + assert.equal(group.previewEditor!.matches(input1), true); assert.equal(group.isActive(input1), true); }); @@ -1003,10 +1003,10 @@ suite('Workbench editor groups', () => { assert.equal(group1.count, 3); assert.equal(group2.count, 3); - assert.equal(group1.activeEditor.matches(g1_input2), true); - assert.equal(group2.activeEditor.matches(g2_input1), true); - assert.equal(group1.previewEditor.matches(g1_input2), true); - assert.equal(group2.previewEditor.matches(g2_input2), true); + assert.equal(group1.activeEditor!.matches(g1_input2), true); + assert.equal(group2.activeEditor!.matches(g2_input1), true); + assert.equal(group1.previewEditor!.matches(g1_input2), true); + assert.equal(group2.previewEditor!.matches(g2_input2), true); assert.equal(group1.getEditors(true)[0].matches(g1_input2), true); assert.equal(group1.getEditors(true)[1].matches(g1_input1), true); @@ -1022,10 +1022,10 @@ suite('Workbench editor groups', () => { assert.equal(group1.count, 3); assert.equal(group2.count, 3); - assert.equal(group1.activeEditor.matches(g1_input2), true); - assert.equal(group2.activeEditor.matches(g2_input1), true); - assert.equal(group1.previewEditor.matches(g1_input2), true); - assert.equal(group2.previewEditor.matches(g2_input2), true); + assert.equal(group1.activeEditor!.matches(g1_input2), true); + assert.equal(group2.activeEditor!.matches(g2_input1), true); + assert.equal(group1.previewEditor!.matches(g1_input2), true); + assert.equal(group2.previewEditor!.matches(g2_input2), true); assert.equal(group1.getEditors(true)[0].matches(g1_input2), true); assert.equal(group1.getEditors(true)[1].matches(g1_input1), true); @@ -1062,8 +1062,8 @@ suite('Workbench editor groups', () => { group.openEditor(serializableInput2, { active: false, pinned: true }); assert.equal(group.count, 3); - assert.equal(group.activeEditor.matches(nonSerializableInput2), true); - assert.equal(group.previewEditor.matches(nonSerializableInput2), true); + assert.equal(group.activeEditor!.matches(nonSerializableInput2), true); + assert.equal(group.previewEditor!.matches(nonSerializableInput2), true); assert.equal(group.getEditors(true)[0].matches(nonSerializableInput2), true); assert.equal(group.getEditors(true)[1].matches(serializableInput1), true); @@ -1073,7 +1073,7 @@ suite('Workbench editor groups', () => { group = inst.createInstance(EditorGroup, group.serialize()); assert.equal(group.count, 2); - assert.equal(group.activeEditor.matches(serializableInput1), true); + assert.equal(group.activeEditor!.matches(serializableInput1), true); assert.equal(group.previewEditor, null); assert.equal(group.getEditors(true)[0].matches(serializableInput1), true); diff --git a/src/vs/workbench/test/common/editor/editorModel.test.ts b/src/vs/workbench/test/common/editor/editorModel.test.ts index 86a83a7599741..513d2783fa1f5 100644 --- a/src/vs/workbench/test/common/editor/editorModel.test.ts +++ b/src/vs/workbench/test/common/editor/editorModel.test.ts @@ -64,7 +64,7 @@ suite('Workbench editor model', () => { let m = new MyTextEditorModel(modelService, modeService); return m.load().then((model: MyTextEditorModel) => { assert(model === m); - model.createTextEditorModel(createTextBufferFactory('foo'), null, 'text/plain'); + model.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain'); assert.strictEqual(m.isResolved(), true); }).then(() => { m.dispose(); diff --git a/src/vs/workbench/test/common/editor/resourceEditorInput.test.ts b/src/vs/workbench/test/common/editor/resourceEditorInput.test.ts index 873c498d0aa0f..e3195191ae4a3 100644 --- a/src/vs/workbench/test/common/editor/resourceEditorInput.test.ts +++ b/src/vs/workbench/test/common/editor/resourceEditorInput.test.ts @@ -32,7 +32,7 @@ suite('Workbench resource editor input', () => { }); test('simple', () => { - let resource = URI.from({ scheme: 'inmemory', authority: null, path: 'thePath' }); + let resource = URI.from({ scheme: 'inmemory', authority: null!, path: 'thePath' }); accessor.modelService.createModel('function test() {}', accessor.modeService.create('text'), resource); let input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource); diff --git a/src/vs/workbench/test/common/editor/untitledEditor.test.ts b/src/vs/workbench/test/common/editor/untitledEditor.test.ts index 2a185efab0bd8..c5df4077e8cce 100644 --- a/src/vs/workbench/test/common/editor/untitledEditor.test.ts +++ b/src/vs/workbench/test/common/editor/untitledEditor.test.ts @@ -202,7 +202,7 @@ suite('Workbench untitled editors', () => { config.setUserConfiguration('files', { 'defaultLanguage': defaultLanguage }); const service = accessor.untitledEditorService; - const input = service.createOrGet(null, modeId); + const input = service.createOrGet(null!, modeId); assert.equal(input.getModeId(), modeId); diff --git a/src/vs/workbench/test/common/memento.test.ts b/src/vs/workbench/test/common/memento.test.ts index 1e733586323e5..b6179a6506aad 100644 --- a/src/vs/workbench/test/common/memento.test.ts +++ b/src/vs/workbench/test/common/memento.test.ts @@ -44,12 +44,12 @@ suite('Memento', () => { assert.deepEqual(memento, { foo: 'Hello World' }); // Assert the Mementos are stored properly in storage - assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.GLOBAL)), { foo: [1, 2, 3] }); + assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.GLOBAL)!), { foo: [1, 2, 3] }); - assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)), { foo: 'Hello World' }); + assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)!), { foo: 'Hello World' }); // Delete Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); delete memento.foo; // Delete Workspace @@ -59,7 +59,7 @@ suite('Memento', () => { myMemento.saveMemento(); // Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); assert.deepEqual(memento, {}); // Workspace @@ -67,16 +67,16 @@ suite('Memento', () => { assert.deepEqual(memento, {}); // Assert the Mementos are also removed from storage - assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null), null); + assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null!), null); - assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null), null); + assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null!), null); }); test('Save and Load', () => { let myMemento = new Memento('memento.test', storage); // Global - let memento: any = myMemento.getMemento(context); + let memento: any = myMemento.getMemento(context!); memento.foo = [1, 2, 3]; // Workspace @@ -87,7 +87,7 @@ suite('Memento', () => { myMemento.saveMemento(); // Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); assert.deepEqual(memento, { foo: [1, 2, 3] }); let globalMemento = myMemento.getMemento(StorageScope.GLOBAL); assert.deepEqual(globalMemento, memento); @@ -97,7 +97,7 @@ suite('Memento', () => { assert.deepEqual(memento, { foo: 'Hello World' }); // Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); memento.foo = [4, 5, 6]; // Workspace @@ -108,7 +108,7 @@ suite('Memento', () => { myMemento.saveMemento(); // Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); assert.deepEqual(memento, { foo: [4, 5, 6] }); globalMemento = myMemento.getMemento(StorageScope.GLOBAL); assert.deepEqual(globalMemento, memento); @@ -118,7 +118,7 @@ suite('Memento', () => { assert.deepEqual(memento, { foo: 'World Hello' }); // Delete Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); delete memento.foo; // Delete Workspace @@ -128,7 +128,7 @@ suite('Memento', () => { myMemento.saveMemento(); // Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); assert.deepEqual(memento, {}); // Workspace @@ -141,10 +141,10 @@ suite('Memento', () => { let myMemento2 = new Memento('memento.test', storage); // Global - let memento: any = myMemento.getMemento(context); + let memento: any = myMemento.getMemento(context!); memento.foo = [1, 2, 3]; - memento = myMemento2.getMemento(context); + memento = myMemento2.getMemento(context!); memento.bar = [1, 2, 3]; // Workspace @@ -160,12 +160,12 @@ suite('Memento', () => { myMemento2.saveMemento(); // Global - memento = myMemento.getMemento(context); + memento = myMemento.getMemento(context!); assert.deepEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] }); let globalMemento = myMemento.getMemento(StorageScope.GLOBAL); assert.deepEqual(globalMemento, memento); - memento = myMemento2.getMemento(context); + memento = myMemento2.getMemento(context!); assert.deepEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] }); globalMemento = myMemento2.getMemento(StorageScope.GLOBAL); assert.deepEqual(globalMemento, memento); diff --git a/src/vs/workbench/test/electron-browser/api/extHostCommands.test.ts b/src/vs/workbench/test/electron-browser/api/extHostCommands.test.ts index 3d43c5d745b8e..979d764834eda 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostCommands.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostCommands.test.ts @@ -26,9 +26,9 @@ suite('ExtHostCommands', function () { } }; - const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService()); + const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined!, new NullLogService()); commands.registerCommand(true, 'foo', (): any => { }).dispose(); - assert.equal(lastUnregister, 'foo'); + assert.equal(lastUnregister!, 'foo'); assert.equal(CommandsRegistry.getCommand('foo'), undefined); }); @@ -46,7 +46,7 @@ suite('ExtHostCommands', function () { } }; - const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService()); + const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined!, new NullLogService()); const reg = commands.registerCommand(true, 'foo', (): any => { }); reg.dispose(); reg.dispose(); diff --git a/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts index 32d0c456cf256..de772e5d0242c 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts @@ -37,7 +37,7 @@ suite('ExtHostDiagnostics', () => { assert.throws(() => collection.get(URI.parse('aa:bb'))); assert.throws(() => collection.has(URI.parse('aa:bb'))); assert.throws(() => collection.set(URI.parse('aa:bb'), [])); - assert.throws(() => collection.set(URI.parse('aa:bb'), undefined)); + assert.throws(() => collection.set(URI.parse('aa:bb'), undefined!)); }); @@ -132,7 +132,7 @@ suite('ExtHostDiagnostics', () => { collection.set([ [uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]], [URI.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]], - [uri, undefined] + [uri, undefined!] ]); assert.ok(!collection.has(uri)); @@ -144,7 +144,7 @@ suite('ExtHostDiagnostics', () => { collection.set([ [uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-1')]], [URI.parse('some:thing'), [new Diagnostic(new Range(0, 0, 1, 1), 'something')]], - [uri, undefined], + [uri, undefined!], [uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-2')]], [uri, [new Diagnostic(new Range(0, 0, 0, 1), 'message-3')]], ]); @@ -160,7 +160,7 @@ suite('ExtHostDiagnostics', () => { test('diagnostics collection, set tuple overrides, #11547', function () { - let lastEntries: [UriComponents, IMarkerData[]][]; + let lastEntries!: [UriComponents, IMarkerData[]][]; let collection = new DiagnosticCollection('test', 'test', 100, new class extends DiagnosticsShape { $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void { lastEntries = entries; @@ -176,7 +176,7 @@ suite('ExtHostDiagnostics', () => { let [[, data1]] = lastEntries; assert.equal(data1.length, 1); assert.equal(data1[0].message, 'error'); - lastEntries = undefined; + lastEntries = undefined!; collection.set([[uri, [new Diagnostic(new Range(0, 0, 1, 1), 'warning')]]]); assert.equal(collection.get(uri).length, 1); @@ -185,7 +185,7 @@ suite('ExtHostDiagnostics', () => { let [[, data2]] = lastEntries; assert.equal(data2.length, 1); assert.equal(data2[0].message, 'warning'); - lastEntries = undefined; + lastEntries = undefined!; }); test('don\'t send message when not making a change', function () { @@ -222,11 +222,11 @@ suite('ExtHostDiagnostics', () => { collection.set([ [uri, [diag, diag, diag]], - [uri, undefined], + [uri, undefined!], [uri, [diag]], [uri2, [diag, diag]], - [uri2, undefined], + [uri2, undefined!], [uri2, [diag]], ]); @@ -244,7 +244,7 @@ suite('ExtHostDiagnostics', () => { let diag = new Diagnostic(new Range(0, 0, 0, 1), i.toString()); tuples.push([uri, [diag, diag, diag]]); - tuples.push([uri, undefined]); + tuples.push([uri, undefined!]); tuples.push([uri, [diag]]); } @@ -259,7 +259,7 @@ suite('ExtHostDiagnostics', () => { test('diagnostic capping', function () { - let lastEntries: [UriComponents, IMarkerData[]][]; + let lastEntries!: [UriComponents, IMarkerData[]][]; let collection = new DiagnosticCollection('test', 'test', 250, new class extends DiagnosticsShape { $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void { lastEntries = entries; @@ -341,7 +341,7 @@ suite('ExtHostDiagnostics', () => { p = Event.toPromise(emitter.event).then(e => { assert.equal(e[0].toString(), 'aa:bb'); }); - collection.set(URI.parse('aa:bb'), undefined); + collection.set(URI.parse('aa:bb'), undefined!); await p; }); @@ -355,9 +355,9 @@ suite('ExtHostDiagnostics', () => { assert.equal(data.length, 1); let [diag] = data; - assert.equal(diag.relatedInformation.length, 2); - assert.equal(diag.relatedInformation[0].message, 'more1'); - assert.equal(diag.relatedInformation[1].message, 'more2'); + assert.equal(diag.relatedInformation!.length, 2); + assert.equal(diag.relatedInformation![0].message, 'more1'); + assert.equal(diag.relatedInformation![1].message, 'more2'); done(); } }, new Emitter()); diff --git a/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts index c6bf32b0bfd7c..0c55c052e4b8e 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts @@ -30,7 +30,7 @@ suite('ExtHostDocumentData', () => { } setup(function () { - data = new ExtHostDocumentData(undefined, URI.file(''), [ + data = new ExtHostDocumentData(undefined!, URI.file(''), [ 'This is line one', //16 'and this is line number two', //27 'it is followed by #3', //20 @@ -39,7 +39,7 @@ suite('ExtHostDocumentData', () => { }); test('readonly-ness', () => { - assert.throws((): void => (data as any).document.uri = null); + assert.throws(() => (data as any).document.uri = null); assert.throws(() => (data as any).document.fileName = 'foofile'); assert.throws(() => (data as any).document.isDirty = false); assert.throws(() => (data as any).document.isUntitled = false); @@ -98,12 +98,12 @@ suite('ExtHostDocumentData', () => { data.onEvents({ changes: [{ range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 }, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: '\t ' }], - eol: undefined, - versionId: undefined, + eol: undefined!, + versionId: undefined!, }); // line didn't change @@ -155,12 +155,12 @@ suite('ExtHostDocumentData', () => { data.onEvents({ changes: [{ range: { startLineNumber: 1, startColumn: 3, endLineNumber: 1, endColumn: 6 }, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: '' }], - eol: undefined, - versionId: undefined, + eol: undefined!, + versionId: undefined!, }); assertOffsetAt(0, 1, 1); @@ -173,12 +173,12 @@ suite('ExtHostDocumentData', () => { data.onEvents({ changes: [{ range: { startLineNumber: 1, startColumn: 3, endLineNumber: 1, endColumn: 6 }, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: 'is could be' }], - eol: undefined, - versionId: undefined, + eol: undefined!, + versionId: undefined!, }); assertOffsetAt(0, 1, 1); @@ -191,12 +191,12 @@ suite('ExtHostDocumentData', () => { data.onEvents({ changes: [{ range: { startLineNumber: 1, startColumn: 3, endLineNumber: 1, endColumn: 6 }, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: 'is could be\na line with number' }], - eol: undefined, - versionId: undefined, + eol: undefined!, + versionId: undefined!, }); assertOffsetAt(0, 1, 1); @@ -212,12 +212,12 @@ suite('ExtHostDocumentData', () => { data.onEvents({ changes: [{ range: { startLineNumber: 1, startColumn: 3, endLineNumber: 2, endColumn: 6 }, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: '' }], - eol: undefined, - versionId: undefined, + eol: undefined!, + versionId: undefined!, }); assertOffsetAt(0, 1, 1); @@ -240,41 +240,41 @@ suite('ExtHostDocumentData', () => { }); test('getWordRangeAtPosition', () => { - data = new ExtHostDocumentData(undefined, URI.file(''), [ + data = new ExtHostDocumentData(undefined!, URI.file(''), [ 'aaaa bbbb+cccc abc' ], '\n', 'text', 1, false); - let range = data.document.getWordRangeAtPosition(new Position(0, 2)); + let range = data.document.getWordRangeAtPosition(new Position(0, 2))!; assert.equal(range.start.line, 0); assert.equal(range.start.character, 0); assert.equal(range.end.line, 0); assert.equal(range.end.character, 4); // ignore bad regular expresson /.*/ - range = data.document.getWordRangeAtPosition(new Position(0, 2), /.*/); + range = data.document.getWordRangeAtPosition(new Position(0, 2), /.*/)!; assert.equal(range.start.line, 0); assert.equal(range.start.character, 0); assert.equal(range.end.line, 0); assert.equal(range.end.character, 4); - range = data.document.getWordRangeAtPosition(new Position(0, 5), /[a-z+]+/); + range = data.document.getWordRangeAtPosition(new Position(0, 5), /[a-z+]+/)!; assert.equal(range.start.line, 0); assert.equal(range.start.character, 5); assert.equal(range.end.line, 0); assert.equal(range.end.character, 14); - range = data.document.getWordRangeAtPosition(new Position(0, 17), /[a-z+]+/); + range = data.document.getWordRangeAtPosition(new Position(0, 17), /[a-z+]+/)!; assert.equal(range.start.line, 0); assert.equal(range.start.character, 15); assert.equal(range.end.line, 0); assert.equal(range.end.character, 18); - range = data.document.getWordRangeAtPosition(new Position(0, 11), /yy/); + range = data.document.getWordRangeAtPosition(new Position(0, 11), /yy/)!; assert.equal(range, undefined); }); test('getWordRangeAtPosition doesn\'t quite use the regex as expected, #29102', function () { - data = new ExtHostDocumentData(undefined, URI.file(''), [ + data = new ExtHostDocumentData(undefined!, URI.file(''), [ 'some text here', '/** foo bar */', 'function() {', @@ -285,7 +285,7 @@ suite('ExtHostDocumentData', () => { let range = data.document.getWordRangeAtPosition(new Position(0, 0), /\/\*.+\*\//); assert.equal(range, undefined); - range = data.document.getWordRangeAtPosition(new Position(1, 0), /\/\*.+\*\//); + range = data.document.getWordRangeAtPosition(new Position(1, 0), /\/\*.+\*\//)!; assert.equal(range.start.line, 1); assert.equal(range.start.character, 0); assert.equal(range.end.line, 1); @@ -294,7 +294,7 @@ suite('ExtHostDocumentData', () => { range = data.document.getWordRangeAtPosition(new Position(3, 0), /("|').*\1/); assert.equal(range, undefined); - range = data.document.getWordRangeAtPosition(new Position(3, 1), /("|').*\1/); + range = data.document.getWordRangeAtPosition(new Position(3, 1), /("|').*\1/)!; assert.equal(range.start.line, 3); assert.equal(range.start.character, 1); assert.equal(range.end.line, 3); @@ -346,17 +346,17 @@ suite('ExtHostDocumentData updates line mapping', () => { return { changes: [{ range: range, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: text }], - eol: eol, - versionId: undefined, + eol: eol!, + versionId: undefined!, }; } function testLineMappingDirectionAfterEvents(lines: string[], eol: string, direction: AssertDocumentLineMappingDirection, e: IModelChangedEvent): void { - let myDocument = new ExtHostDocumentData(undefined, URI.file(''), lines.slice(0), eol, 'text', 1, false); + let myDocument = new ExtHostDocumentData(undefined!, URI.file(''), lines.slice(0), eol, 'text', 1, false); assertDocumentLineMapping(myDocument, direction); myDocument.onEvents(e); @@ -377,7 +377,7 @@ suite('ExtHostDocumentData updates line mapping', () => { 'and this is line number two', 'it is followed by #3', 'and finished with the fourth.', - ], { changes: [], eol: undefined, versionId: 7 }); + ], { changes: [], eol: undefined!, versionId: 7 }); }); test('after remove', () => { diff --git a/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts index 695bb6098f72f..e631e129ef56f 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts @@ -30,11 +30,11 @@ suite('ExtHostDocumentSaveParticipant', () => { name: 'Null Extension Description', publisher: 'vscode', enableProposedApi: false, - engines: undefined, - extensionLocation: undefined, + engines: undefined!, + extensionLocation: undefined!, isBuiltin: false, isUnderDevelopment: false, - version: undefined + version: undefined! }; setup(() => { @@ -86,7 +86,7 @@ suite('ExtHostDocumentSaveParticipant', () => { sub.dispose(); assert.ok(event); - assert.throws(() => { event.document = null; }); + assert.throws(() => { event.document = null!; }); }); }); @@ -301,11 +301,11 @@ suite('ExtHostDocumentSaveParticipant', () => { documents.$acceptModelChanged(resource, { changes: [{ range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 }, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, text: 'bar' }], - eol: undefined, + eol: undefined!, versionId: 2 }, true); @@ -337,10 +337,10 @@ suite('ExtHostDocumentSaveParticipant', () => { changes: [{ range, text, - rangeOffset: undefined, - rangeLength: undefined, + rangeOffset: undefined!, + rangeLength: undefined!, }], - eol: undefined, + eol: undefined!, versionId: documents.getDocumentData(uri).version + 1 }, true); } diff --git a/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts index 9230a858c78c9..64ea0f9f7f9ea 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDocumentsAndEditors.test.ts @@ -13,9 +13,9 @@ suite('ExtHostDocumentsAndEditors', () => { setup(function () { editors = new ExtHostDocumentsAndEditors({ - getProxy: () => { return undefined; }, - set: undefined, - assertRegistered: undefined + getProxy: () => { return undefined!; }, + set: undefined!, + assertRegistered: undefined! }); }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts b/src/vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts index 93d64572b335b..b9a299dc60c44 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostFileSystemEventService.test.ts @@ -12,17 +12,17 @@ suite('ExtHostFileSystemEventService', () => { test('FileSystemWatcher ignore events properties are reversed #26851', function () { const protocol: IMainContext = { - getProxy: () => { return undefined; }, - set: undefined, - assertRegistered: undefined + getProxy: () => { return undefined!; }, + set: undefined!, + assertRegistered: undefined! }; - const watcher1 = new ExtHostFileSystemEventService(protocol, undefined).createFileSystemWatcher('**/somethingInteresting', false, false, false); + const watcher1 = new ExtHostFileSystemEventService(protocol, undefined!).createFileSystemWatcher('**/somethingInteresting', false, false, false); assert.equal(watcher1.ignoreChangeEvents, false); assert.equal(watcher1.ignoreCreateEvents, false); assert.equal(watcher1.ignoreDeleteEvents, false); - const watcher2 = new ExtHostFileSystemEventService(protocol, undefined).createFileSystemWatcher('**/somethingBoring', true, true, true); + const watcher2 = new ExtHostFileSystemEventService(protocol, undefined!).createFileSystemWatcher('**/somethingBoring', true, true, true); assert.equal(watcher2.ignoreChangeEvents, true); assert.equal(watcher2.ignoreCreateEvents, true); assert.equal(watcher2.ignoreDeleteEvents, true); diff --git a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts index 49136918e5d88..e403ec1ebe91f 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts @@ -78,9 +78,9 @@ suite('ExtHostMessageService', function () { test('propagte handle on select', async function () { - let service = new MainThreadMessageService(null, new EmptyNotificationService(notification => { - assert.equal(notification.actions.primary.length, 1); - setImmediate(() => notification.actions.primary[0].run()); + let service = new MainThreadMessageService(null!, new EmptyNotificationService(notification => { + assert.equal(notification.actions!.primary!.length, 1); + setImmediate(() => notification.actions!.primary![0].run()); }), emptyCommandService, emptyDialogService); const handle = await service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]); @@ -89,7 +89,7 @@ suite('ExtHostMessageService', function () { suite('modal', () => { test('calls dialog service', async () => { - const service = new MainThreadMessageService(null, emptyNotificationService, emptyCommandService, new class extends mock() { + const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock() { show(severity, message, buttons) { assert.equal(severity, 1); assert.equal(message, 'h'); @@ -104,7 +104,7 @@ suite('ExtHostMessageService', function () { }); test('returns undefined when cancelled', async () => { - const service = new MainThreadMessageService(null, emptyNotificationService, emptyCommandService, new class extends mock() { + const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock() { show(severity, message, buttons) { return Promise.resolve(1); } @@ -115,7 +115,7 @@ suite('ExtHostMessageService', function () { }); test('hides Cancel button when not needed', async () => { - const service = new MainThreadMessageService(null, emptyNotificationService, emptyCommandService, new class extends mock() { + const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock() { show(severity, message, buttons) { assert.equal(buttons.length, 1); return Promise.resolve(0); diff --git a/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts b/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts index a94f9d7f7ed06..1eb1b00694f3f 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts @@ -100,7 +100,7 @@ suite('ExtHostSearch', () => { await rpcProtocol.sync(); return { results: (mockMainThreadSearch.results).map(r => URI.revive(r)), - stats + stats: stats! }; } @@ -130,7 +130,7 @@ suite('ExtHostSearch', () => { } })); - return { results, stats }; + return { results, stats: stats! }; } setup(() => { @@ -143,7 +143,7 @@ suite('ExtHostSearch', () => { rpcProtocol.set(MainContext.MainThreadSearch, mockMainThreadSearch); mockExtfs = {}; - extHostSearch = new ExtHostSearch(rpcProtocol, null, logService, ehConfiguration, mockExtfs as typeof extfs); + extHostSearch = new ExtHostSearch(rpcProtocol, null!, logService, ehConfiguration, mockExtfs as typeof extfs); }); teardown(() => { @@ -180,7 +180,7 @@ suite('ExtHostSearch', () => { test('no results', async () => { await registerTestFileSearchProvider({ provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise { - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -230,7 +230,7 @@ suite('ExtHostSearch', () => { test('provider returns null', async () => { await registerTestFileSearchProvider({ provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise { - return null; + return null!; } }); @@ -246,7 +246,7 @@ suite('ExtHostSearch', () => { await registerTestFileSearchProvider({ provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise { assert(options.excludes.length === 2 && options.includes.length === 2, 'Missing global include/excludes'); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -282,7 +282,7 @@ suite('ExtHostSearch', () => { assert.deepEqual(options.excludes.sort(), ['*.js']); } - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -319,7 +319,7 @@ suite('ExtHostSearch', () => { assert.deepEqual(options.includes.sort(), ['*.jsx', '*.ts']); assert.deepEqual(options.excludes.sort(), []); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -661,7 +661,7 @@ suite('ExtHostSearch', () => { const actualTextSearchResults: vscode.TextSearchResult[] = []; for (let fileMatch of actual) { // Make relative - for (let lineResult of fileMatch.results) { + for (let lineResult of fileMatch.results!) { if (resultIsMatch(lineResult)) { actualTextSearchResults.push({ preview: { @@ -715,7 +715,7 @@ suite('ExtHostSearch', () => { test('no results', async () => { await registerTestTextSearchProvider({ provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -733,7 +733,7 @@ suite('ExtHostSearch', () => { await registerTestTextSearchProvider({ provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -747,7 +747,7 @@ suite('ExtHostSearch', () => { provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { assert.equal(options.includes.length, 1); assert.equal(options.excludes.length, 1); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -783,7 +783,7 @@ suite('ExtHostSearch', () => { assert.deepEqual(options.excludes.sort(), ['*.js']); } - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -820,7 +820,7 @@ suite('ExtHostSearch', () => { assert.deepEqual(options.includes.sort(), ['*.jsx', '*.ts']); assert.deepEqual(options.excludes.sort(), []); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -870,12 +870,12 @@ suite('ExtHostSearch', () => { test('basic sibling clause', async () => { mockExtfs.readdir = (_path: string, callback: (error: Error, files: string[]) => void) => { if (_path === rootFolderA.fsPath) { - callback(null, [ + callback(null!, [ 'file1.js', 'file1.ts' ]); } else { - callback(new Error('Wrong path'), null); + callback(new Error('Wrong path'), null!); } }; @@ -887,7 +887,7 @@ suite('ExtHostSearch', () => { await registerTestTextSearchProvider({ provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -913,19 +913,19 @@ suite('ExtHostSearch', () => { test('multiroot sibling clause', async () => { mockExtfs.readdir = (_path: string, callback: (error: Error, files: string[]) => void) => { if (_path === joinPath(rootFolderA, 'folder').fsPath) { - callback(null, [ + callback(null!, [ 'fileA.scss', 'fileA.css', 'file2.css' ]); } else if (_path === rootFolderB.fsPath) { - callback(null, [ + callback(null!, [ 'fileB.ts', 'fileB.js', 'file3.js' ]); } else { - callback(new Error('Wrong path'), null); + callback(new Error('Wrong path'), null!); } }; @@ -947,7 +947,7 @@ suite('ExtHostSearch', () => { } reportedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -997,7 +997,7 @@ suite('ExtHostSearch', () => { await registerTestTextSearchProvider({ provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -1029,7 +1029,7 @@ suite('ExtHostSearch', () => { provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { token.onCancellationRequested(() => wasCanceled = true); providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -1062,7 +1062,7 @@ suite('ExtHostSearch', () => { provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { token.onCancellationRequested(() => wasCanceled = true); providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -1094,7 +1094,7 @@ suite('ExtHostSearch', () => { provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { token.onCancellationRequested(() => wasCanceled = true); providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }); @@ -1156,7 +1156,7 @@ suite('ExtHostSearch', () => { 'file2.ts', 'file3.ts', ].forEach(f => progress.report(makeTextResult(options.folder, f))); - return null; + return null!; } }); @@ -1187,7 +1187,7 @@ suite('ExtHostSearch', () => { await registerTestTextSearchProvider({ provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Promise { providedResults.forEach(r => progress.report(r)); - return Promise.resolve(null); + return Promise.resolve(null!); } }, fancyScheme); diff --git a/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts index f61888da15328..a8f269a3dad23 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts @@ -14,12 +14,12 @@ import { mock } from 'vs/workbench/test/electron-browser/api/mock'; suite('ExtHostTextEditor', () => { let editor: ExtHostTextEditor; - let doc = new ExtHostDocumentData(undefined, URI.file(''), [ + let doc = new ExtHostDocumentData(undefined!, URI.file(''), [ 'aaaa bbbb+cccc abc' ], '\n', 'text', 1, false); setup(() => { - editor = new ExtHostTextEditor(null, 'fake', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1); + editor = new ExtHostTextEditor(null!, 'fake', doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1); }); test('disposed editor', () => { @@ -34,7 +34,7 @@ suite('ExtHostTextEditor', () => { assert.equal(3, editor.viewColumn); assert.ok(editor.document); - assert.throws(() => editor._acceptOptions(null)); + assert.throws(() => editor._acceptOptions(null!)); assert.throws(() => editor._acceptSelections([])); }); @@ -66,25 +66,25 @@ suite('ExtHostTextEditorOptions', () => { setup(() => { calls = []; let mockProxy: MainThreadTextEditorsShape = { - dispose: undefined, + dispose: undefined!, $trySetOptions: (id: string, options: ITextEditorConfigurationUpdate) => { assert.equal(id, '1'); calls.push(options); return Promise.resolve(void 0); }, - $tryShowTextDocument: undefined, - $registerTextEditorDecorationType: undefined, - $removeTextEditorDecorationType: undefined, - $tryShowEditor: undefined, - $tryHideEditor: undefined, - $trySetDecorations: undefined, - $trySetDecorationsFast: undefined, - $tryRevealRange: undefined, - $trySetSelections: undefined, - $tryApplyEdits: undefined, - $tryApplyWorkspaceEdit: undefined, - $tryInsertSnippet: undefined, - $getDiffInformation: undefined + $tryShowTextDocument: undefined!, + $registerTextEditorDecorationType: undefined!, + $removeTextEditorDecorationType: undefined!, + $tryShowEditor: undefined!, + $tryHideEditor: undefined!, + $trySetDecorations: undefined!, + $trySetDecorationsFast: undefined!, + $tryRevealRange: undefined!, + $trySetSelections: undefined!, + $tryApplyEdits: undefined!, + $tryApplyWorkspaceEdit: undefined!, + $tryInsertSnippet: undefined!, + $getDiffInformation: undefined! }; opts = new ExtHostTextEditorOptions(mockProxy, '1', { tabSize: 4, @@ -95,8 +95,8 @@ suite('ExtHostTextEditorOptions', () => { }); teardown(() => { - opts = null; - calls = null; + opts = null!; + calls = null!; }); function assertState(opts: ExtHostTextEditorOptions, expected: IResolvedTextEditorConfiguration): void { @@ -165,7 +165,7 @@ suite('ExtHostTextEditorOptions', () => { }); test('ignores invalid tabSize 1', () => { - opts.tabSize = null; + opts.tabSize = null!; assertState(opts, { tabSize: 4, insertSpaces: false, diff --git a/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts index 0190c3baa5117..10cb6493faf22 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts @@ -19,7 +19,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => { let workspaceResourceEdits: WorkspaceEditDto; setup(() => { - workspaceResourceEdits = null; + workspaceResourceEdits = null!; let rpcProtocol = new TestRPCProtocol(); rpcProtocol.set(MainContext.MainThreadTextEditors, new class extends mock() { diff --git a/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts index 7f67a1cea9d5d..748289d7fea7d 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts @@ -29,34 +29,34 @@ suite('ExtHostTypeConverter', function () { data = MarkdownString.from('Hello [link](foo:path)'); assert.equal(data.value, 'Hello [link](foo:path)'); - assert.equal(size(data.uris), 1); - assert.ok(!!data.uris['foo:path']); + assert.equal(size(data.uris!), 1); + assert.ok(!!data.uris!['foo:path']); data = MarkdownString.from('hello@foo.bar'); assert.equal(data.value, 'hello@foo.bar'); - assert.equal(size(data.uris), 1); - assert.ok(!!data.uris['mailto:hello@foo.bar']); + assert.equal(size(data.uris!), 1); + assert.ok(!!data.uris!['mailto:hello@foo.bar']); data = MarkdownString.from('*hello* [click](command:me)'); assert.equal(data.value, '*hello* [click](command:me)'); - assert.equal(size(data.uris), 1); - assert.ok(!!data.uris['command:me']); + assert.equal(size(data.uris!), 1); + assert.ok(!!data.uris!['command:me']); data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here)'); assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)'); - assert.equal(size(data.uris), 1); - assert.ok(!!data.uris['file:///somepath/here']); + assert.equal(size(data.uris!), 1); + assert.ok(!!data.uris!['file:///somepath/here']); data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here)'); assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)'); - assert.equal(size(data.uris), 1); - assert.ok(!!data.uris['file:///somepath/here']); + assert.equal(size(data.uris!), 1); + assert.ok(!!data.uris!['file:///somepath/here']); data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here2)'); assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here2)'); - assert.equal(size(data.uris), 2); - assert.ok(!!data.uris['file:///somepath/here']); - assert.ok(!!data.uris['file:///somepath/here2']); + assert.equal(size(data.uris!), 2); + assert.ok(!!data.uris!['file:///somepath/here']); + assert.ok(!!data.uris!['file:///somepath/here2']); }); test('LogLevel', () => { diff --git a/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts b/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts index 17af41aaced9e..557aa5868c959 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostWorkspace.test.ts @@ -23,11 +23,11 @@ suite('ExtHostWorkspace', function () { name: 'ext', publisher: 'vscode', enableProposedApi: false, - engines: undefined, - extensionLocation: undefined, + engines: undefined!, + extensionLocation: undefined!, isBuiltin: false, isUnderDevelopment: false, - version: undefined + version: undefined! }; function assertAsRelativePath(workspace: ExtHostWorkspace, input: string, expected: string, includeWorkspace?: boolean) { @@ -64,7 +64,7 @@ suite('ExtHostWorkspace', function () { }); test('asRelativePath, no workspace', function () { - const ws = new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()); + const ws = new ExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter()); assertAsRelativePath(ws, (''), ''); assertAsRelativePath(ws, ('/foo/bar'), '/foo/bar'); }); @@ -102,10 +102,10 @@ suite('ExtHostWorkspace', function () { let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter()); assert.equal(ws.getPath(), undefined); - ws = new ExtHostWorkspace(new TestRPCProtocol(), null, new NullLogService(), new Counter()); + ws = new ExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService(), new Counter()); assert.equal(ws.getPath(), undefined); - ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined, new NullLogService(), new Counter()); + ws = new ExtHostWorkspace(new TestRPCProtocol(), undefined!, new NullLogService(), new Counter()); assert.equal(ws.getPath(), undefined); ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService(), new Counter()); @@ -260,7 +260,7 @@ suite('ExtHostWorkspace', function () { test('updateWorkspaceFolders - invalid arguments', function () { let ws = new ExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter()); - assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null, null)); + assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null!, null!)); assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0)); assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 1)); assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0)); @@ -284,9 +284,9 @@ suite('ExtHostWorkspace', function () { }; const protocol: IMainContext = { - getProxy: () => { return undefined; }, - set: undefined, - assertRegistered: undefined + getProxy: () => { return undefined!; }, + set: undefined!, + assertRegistered: undefined! }; const ws = new ExtHostWorkspace(protocol, { id: 'foo', name: 'Test', folders: [] }, new NullLogService(), new Counter()); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadCommands.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadCommands.test.ts index 506f1f152b64b..5902e8e757bf2 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadCommands.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadCommands.test.ts @@ -12,7 +12,7 @@ suite('MainThreadCommands', function () { test('dispose on unregister', function () { - const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined); + const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!); assert.equal(CommandsRegistry.getCommand('foo'), undefined); // register @@ -26,7 +26,7 @@ suite('MainThreadCommands', function () { test('unregister all on dispose', function () { - const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined); + const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!); assert.equal(CommandsRegistry.getCommand('foo'), undefined); commands.$registerCommand('foo'); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadDiagnostics.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadDiagnostics.test.ts index 733bb3eae4ba7..8d855237d593d 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadDiagnostics.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadDiagnostics.test.ts @@ -19,7 +19,7 @@ suite('MainThreadDiagnostics', function () { test('clear markers on dispose', function () { - let diag = new MainThreadDiagnostics(null, markerService); + let diag = new MainThreadDiagnostics(null!, markerService); diag.$changeMany('foo', [[URI.file('a'), [{ code: '666', diff --git a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts index 4078a988a688c..9b3374803baa6 100644 --- a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts @@ -137,7 +137,7 @@ suite.skip('QuickOpen performance (integration)', () => { let i = n; return (function iterate(): Promise { if (!i--) { - return undefined; + return undefined!; } return measure() .then(([uncachedEvent, cachedEvent]) => { diff --git a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts index eb19c5d741cca..61591b0584c9b 100644 --- a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts @@ -117,7 +117,7 @@ suite.skip('TextSearch performance (integration)', () => { }); } - const finishedEvents = []; + const finishedEvents: any[] = []; return runSearch() // Warm-up first .then(() => { if (testWorkspaceArg) { // Don't measure by default