From c859e785e3f3b0d9ee638b507c9a81c15aa3ed65 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 21 Dec 2018 00:14:55 -0800 Subject: [PATCH 1/4] Manually added strict null checks in around 70 files --- src/tsconfig.strictNullChecks.json | 64 +++- src/vs/base/common/comparers.ts | 10 +- .../test/common/quickOpenScorer.test.ts | 6 +- .../parts/tree/test/browser/treeModel.test.ts | 2 +- src/vs/base/test/browser/htmlContent.test.ts | 6 +- .../test/browser/ui/grid/gridview.test.ts | 2 +- .../browser/ui/splitview/splitview.test.ts | 4 +- .../browser/ui/tree/asyncDataTree.test.ts | 6 +- src/vs/base/test/common/arrays.test.ts | 2 +- src/vs/base/test/common/async.test.ts | 2 +- src/vs/base/test/common/diff/diff.test.ts | 2 +- src/vs/base/test/common/event.test.ts | 2 +- src/vs/base/test/common/history.test.ts | 2 +- src/vs/base/test/common/keyCodes.test.ts | 4 +- src/vs/base/test/common/map.test.ts | 10 +- src/vs/base/test/common/octicon.test.ts | 2 +- src/vs/base/test/common/strings.test.ts | 2 +- src/vs/base/test/common/uri.test.ts | 4 +- src/vs/base/test/node/config.test.ts | 2 +- src/vs/base/test/node/extfs/extfs.test.ts | 32 +- src/vs/base/test/node/flow.test.ts | 8 +- src/vs/base/test/node/glob.test.ts | 40 +-- src/vs/base/test/node/pfs.test.ts | 12 +- src/vs/base/test/node/storage/storage.test.ts | 4 +- src/vs/code/test/node/windowsFinder.test.ts | 4 +- .../codeAction/test/codeAction.test.ts | 2 +- .../codeAction/test/codeActionModel.test.ts | 8 +- .../comment/test/lineCommentCommand.test.ts | 2 +- .../contrib/find/test/findController.test.ts | 70 ++--- .../contrib/find/test/findModel.test.ts | 110 +++---- .../test/linesOperations.test.ts | 292 +++++++++--------- .../test/moveLinesCommand.test.ts | 2 +- .../multicursor/test/multicursor.test.ts | 102 +++--- .../suggest/test/completionModel.test.ts | 2 +- .../test/wordOperations.test.ts | 94 +++--- .../test/wordPartOperations.test.ts | 30 +- .../test/browser/simpleServices.test.ts | 4 +- .../platform/commands/test/commands.test.ts | 22 +- .../test/common/configurationModels.test.ts | 4 +- .../contextkey/test/common/contextkey.test.ts | 10 +- .../test/node/extensionValidator.test.ts | 2 +- src/vs/platform/files/test/files.test.ts | 4 +- .../test/common/instantiationService.test.ts | 6 +- .../common/abstractKeybindingService.test.ts | 40 +-- .../test/common/keybindingLabels.test.ts | 10 +- .../test/common/keybindingResolver.test.ts | 48 +-- .../markers/test/common/markerService.test.ts | 4 +- .../appInsightsAppender.test.ts | 34 +- .../electron-browser/telemetryService.test.ts | 56 ++-- src/vs/workbench/api/node/extHostTypes.ts | 6 +- .../electron-browser/markersModel.test.ts | 6 +- .../test/electron-browser/snippetFile.test.ts | 2 +- .../electron-browser/snippetsService.test.ts | 46 +-- .../terminal/node/terminalEnvironment.ts | 4 +- .../terminalConfigHelper.test.ts | 28 +- .../terminalLinkHandler.test.ts | 14 +- .../test/node/terminalEnvironment.test.ts | 24 +- .../test/common/commandService.test.ts | 10 +- .../test/common/configurationModels.test.ts | 2 +- .../test/browser/decorationsService.test.ts | 34 +- .../extensions/test/node/rpcProtocol.test.ts | 2 - .../unix/test/chockidarWatcherService.test.ts | 4 +- .../keybinding/test/keybindingIO.test.ts | 2 +- .../test/keyboardMapperTestUtils.ts | 2 +- .../macLinuxFallbackKeyboardMapper.test.ts | 12 +- .../test/macLinuxKeyboardMapper.test.ts | 16 +- .../test/windowsKeyboardMapper.test.ts | 18 +- .../test/common/notifications.test.ts | 20 +- .../electron-browser/api/extHostTypes.test.ts | 52 ++-- 69 files changed, 778 insertions(+), 718 deletions(-) diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index d22a758b61760..b412f0e0f8f4d 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -796,7 +796,69 @@ "./vs/workbench/services/title/common/titleService.ts", "./vs/workbench/services/workspace/common/workspaceEditing.ts", "./vs/workbench/test/common/editor/editorOptions.test.ts", - "./vs/workbench/test/electron-browser/api/mock.ts" + "./vs/workbench/test/electron-browser/api/mock.ts", + "./vs/base/test/browser/comparers.test.ts", + "./vs/base/test/browser/ui/grid/gridview.test.ts", + "./vs/base/test/browser/ui/splitview/splitview.test.ts", + "./vs/base/test/browser/ui/tree/asyncDataTree.test.ts", + "./vs/base/test/common/arrays.test.ts", + "./vs/base/test/common/async.test.ts", + "./vs/base/test/common/diff/diff.test.ts", + "./vs/base/test/common/event.test.ts", + "./vs/base/test/common/history.test.ts", + "./vs/base/test/common/keyCodes.test.ts", + "./vs/base/test/common/map.test.ts", + "./vs/base/test/common/octicon.test.ts", + "./vs/base/test/common/strings.test.ts", + "./vs/base/test/common/uri.test.ts", + "./vs/base/test/node/config.test.ts", + "./vs/base/test/node/extfs/extfs.test.ts", + "./vs/base/test/node/flow.test.ts", + "./vs/base/test/node/glob.test.ts", + "./vs/base/test/node/pfs.test.ts", + "./vs/base/test/node/storage/storage.test.ts", + "./vs/code/test/node/windowsFinder.test.ts", + "./vs/editor/contrib/codeAction/test/codeAction.test.ts", + "./vs/editor/contrib/codeAction/test/codeActionModel.test.ts", + "./vs/editor/contrib/comment/test/lineCommentCommand.test.ts", + "./vs/editor/contrib/find/test/findController.test.ts", + "./vs/editor/contrib/linesOperations/test/linesOperations.test.ts", + "./vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts", + "./vs/editor/contrib/multicursor/test/multicursor.test.ts", + "./vs/editor/contrib/suggest/test/completionModel.test.ts", + "./vs/editor/contrib/wordOperations/test/wordOperations.test.ts", + "./vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts", + "./vs/editor/standalone/test/browser/simpleServices.test.ts", + "./vs/platform/commands/test/commands.test.ts", + "./vs/platform/configuration/test/common/configurationModels.test.ts", + "./vs/platform/contextkey/test/common/contextkey.test.ts", + "./vs/platform/extensions/test/node/extensionValidator.test.ts", + "./vs/platform/files/test/files.test.ts", + "./vs/platform/instantiation/test/common/instantiationService.test.ts", + "./vs/platform/keybinding/test/common/abstractKeybindingService.test.ts", + "./vs/platform/keybinding/test/common/keybindingLabels.test.ts", + "./vs/platform/keybinding/test/common/keybindingResolver.test.ts", + "./vs/platform/markers/test/common/markerService.test.ts", + "./vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts", + "./vs/platform/telemetry/test/electron-browser/telemetryService.test.ts", + "./vs/workbench/parts/markers/test/electron-browser/markersModel.test.ts", + "./vs/workbench/parts/snippets/test/electron-browser/snippetFile.test.ts", + "./vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts", + "./vs/workbench/parts/stats/test/workspaceStats.test.ts", + "./vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts", + "./vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts", + "./vs/workbench/parts/terminal/test/node/terminalEnvironment.test.ts", + "./vs/workbench/services/commands/test/common/commandService.test.ts", + "./vs/workbench/services/configuration/test/common/configurationModels.test.ts", + "./vs/workbench/services/decorations/test/browser/decorationsService.test.ts", + "./vs/workbench/services/extensions/test/node/rpcProtocol.test.ts", + "./vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts", + "./vs/workbench/services/keybinding/test/keybindingIO.test.ts", + "./vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts", + "./vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts", + "./vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts", + "./vs/workbench/test/common/notifications.test.ts", + "./vs/workbench/test/electron-browser/api/extHostTypes.test.ts" ], "exclude": [ "./typings/require-monaco.d.ts" diff --git a/src/vs/base/common/comparers.ts b/src/vs/base/common/comparers.ts index 3a73fa7d4f439..4a7809957902a 100644 --- a/src/vs/base/common/comparers.ts +++ b/src/vs/base/common/comparers.ts @@ -13,7 +13,7 @@ export function setFileNameComparer(collator: IdleValue<{ collator: Intl.Collato intlFileNameCollator = collator; } -export function compareFileNames(one: string, other: string, caseSensitive = false): number { +export function compareFileNames(one: string | null, other: string | null, caseSensitive = false): number { if (intlFileNameCollator) { const a = one || ''; const b = other || ''; @@ -33,7 +33,7 @@ export function compareFileNames(one: string, other: string, caseSensitive = fal const FileNameMatch = /^(.*?)(\.([^.]*))?$/; -export function noIntlCompareFileNames(one: string, other: string, caseSensitive = false): number { +export function noIntlCompareFileNames(one: string | null, other: string | null, caseSensitive = false): number { if (!caseSensitive) { one = one && one.toLowerCase(); other = other && other.toLowerCase(); @@ -53,7 +53,7 @@ export function noIntlCompareFileNames(one: string, other: string, caseSensitive return oneExtension < otherExtension ? -1 : 1; } -export function compareFileExtensions(one: string, other: string): number { +export function compareFileExtensions(one: string | null, other: string | null): number { if (intlFileNameCollator) { const [oneName, oneExtension] = extractNameAndExtension(one); const [otherName, otherExtension] = extractNameAndExtension(other); @@ -81,7 +81,7 @@ export function compareFileExtensions(one: string, other: string): number { return noIntlCompareFileExtensions(one, other); } -function noIntlCompareFileExtensions(one: string, other: string): number { +function noIntlCompareFileExtensions(one: string | null, other: string | null): number { const [oneName, oneExtension] = extractNameAndExtension(one && one.toLowerCase()); const [otherName, otherExtension] = extractNameAndExtension(other && other.toLowerCase()); @@ -96,7 +96,7 @@ function noIntlCompareFileExtensions(one: string, other: string): number { return oneName < otherName ? -1 : 1; } -function extractNameAndExtension(str?: string): [string, string] { +function extractNameAndExtension(str?: string | null): [string, string] { const match = str ? FileNameMatch.exec(str) as Array : ([] as Array); return [(match && match[1]) || '', (match && match[3]) || '']; diff --git a/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts b/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts index 57fb24a9d13af..e7f6fd55ac814 100644 --- a/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts +++ b/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts @@ -28,15 +28,15 @@ const ResourceAccessor = new ResourceAccessorClass(); class NullAccessorClass implements scorer.IItemAccessor { - getItemLabel(resource: URI): string { + getItemLabel(resource: URI): string | undefined { return void 0; } - getItemDescription(resource: URI): string { + getItemDescription(resource: URI): string | undefined { return void 0; } - getItemPath(resource: URI): string { + getItemPath(resource: URI): string | undefined { return void 0; } } 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 03c321bb0ded5..36b3853941cd5 100644 --- a/src/vs/base/parts/tree/test/browser/treeModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeModel.test.ts @@ -72,7 +72,7 @@ class EventCounter { this._count = 0; } - public listen(event: Event, fn: (e: T) => void = null): () => void { + public listen(event: Event, fn: (e: T) => void | null | null = null): () => void { let r = event(data => { this._count++; if (fn) { diff --git a/src/vs/base/test/browser/htmlContent.test.ts b/src/vs/base/test/browser/htmlContent.test.ts index 20db9845e0a0e..be7a575775645 100644 --- a/src/vs/base/test/browser/htmlContent.test.ts +++ b/src/vs/base/test/browser/htmlContent.test.ts @@ -26,7 +26,7 @@ suite('HtmlContent', () => { test('simple formatting', () => { var result: HTMLElement = renderFormattedText('**bold**'); assert.strictEqual(result.children.length, 1); - assert.strictEqual(result.firstChild.textContent, 'bold'); + assert.strictEqual(result.firstChild!.textContent, 'bold'); assert.strictEqual((result.firstChild).tagName, 'B'); assert.strictEqual(result.innerHTML, 'bold'); @@ -62,7 +62,7 @@ suite('HtmlContent', () => { var event: MouseEvent = document.createEvent('MouseEvent'); event.initEvent('click', true, true); - result.firstChild.dispatchEvent(event); + result.firstChild!.dispatchEvent(event); assert.strictEqual(callbackCalled, true); }); @@ -81,7 +81,7 @@ suite('HtmlContent', () => { var event: MouseEvent = document.createEvent('MouseEvent'); event.initEvent('click', true, true); - result.firstChild.firstChild.firstChild.dispatchEvent(event); + result.firstChild!.firstChild!.firstChild!.dispatchEvent(event); assert.strictEqual(callbackCalled, true); }); diff --git a/src/vs/base/test/browser/ui/grid/gridview.test.ts b/src/vs/base/test/browser/ui/grid/gridview.test.ts index 3485fa63b3173..284042b3f249d 100644 --- a/src/vs/base/test/browser/ui/grid/gridview.test.ts +++ b/src/vs/base/test/browser/ui/grid/gridview.test.ts @@ -22,7 +22,7 @@ suite('Gridview', function () { }); teardown(function () { - gridview = null; + gridview = null!; }); test('empty gridview is empty', function () { diff --git a/src/vs/base/test/browser/ui/splitview/splitview.test.ts b/src/vs/base/test/browser/ui/splitview/splitview.test.ts index 185c9f25aa47c..54b49300050df 100644 --- a/src/vs/base/test/browser/ui/splitview/splitview.test.ts +++ b/src/vs/base/test/browser/ui/splitview/splitview.test.ts @@ -73,12 +73,12 @@ suite('Splitview', () => { }); teardown(() => { - container = null; + container = null!; }); test('empty splitview has empty DOM', () => { const splitview = new SplitView(container); - assert.equal(container.firstElementChild.firstElementChild.childElementCount, 0, 'split view should be empty'); + assert.equal(container.firstElementChild!.firstElementChild!.childElementCount, 0, 'split view should be empty'); splitview.dispose(); }); diff --git a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts index 670254527a54a..c02a6c596698a 100644 --- a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts +++ b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts @@ -53,7 +53,7 @@ suite('AsyncDataTree', function () { const dataSource = new class implements IAsyncDataSource { hasChildren(element: Element): boolean { - return element.children && element.children.length > 0; + return (element.children && element.children.length > 0)!; } getChildren(element: Element): Promise { return Promise.resolve(element.children || []); @@ -91,14 +91,14 @@ suite('AsyncDataTree', function () { { id: 'ac' } ]; - await tree.refresh(null); + await tree.refresh(null!); assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); await tree.expand(_('a')); assert.equal(container.querySelectorAll('.monaco-list-row').length, 4); _('a').children = []; - await tree.refresh(null); + await tree.refresh(null!); assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); }); }); \ No newline at end of file diff --git a/src/vs/base/test/common/arrays.test.ts b/src/vs/base/test/common/arrays.test.ts index dbc2162bc1d9b..41788a3a13897 100644 --- a/src/vs/base/test/common/arrays.test.ts +++ b/src/vs/base/test/common/arrays.test.ts @@ -305,7 +305,7 @@ suite('Arrays', () => { assert.equal(a[1], 2); assert.equal(a[2], 3); - a = [null, 1, null, void 0, undefined, 2, 3]; + a = [null, 1, null, undefined!, undefined!, 2, 3]; arrays.coalesceInPlace(a); assert.equal(a.length, 3); assert.equal(a[0], 1); diff --git a/src/vs/base/test/common/async.test.ts b/src/vs/base/test/common/async.test.ts index 76257d436407c..f1b43f32ed055 100644 --- a/src/vs/base/test/common/async.test.ts +++ b/src/vs/base/test/common/async.test.ts @@ -522,7 +522,7 @@ suite('Async', () => { assert.ok(r2Queue); assert.equal(r1Queue, queue.queueFor(URI.file('/some/path'))); // same queue returned - let syncPromiseFactory = () => Promise.resolve(null); + let syncPromiseFactory = () => Promise.resolve(null!); r1Queue.queue(syncPromiseFactory); diff --git a/src/vs/base/test/common/diff/diff.test.ts b/src/vs/base/test/common/diff/diff.test.ts index 70fe3acb59762..913bf26fa506f 100644 --- a/src/vs/base/test/common/diff/diff.test.ts +++ b/src/vs/base/test/common/diff/diff.test.ts @@ -21,7 +21,7 @@ class StringDiffSequence implements ISequence { } function createArray(length: number, value: T): T[] { - var r = []; + var r: T[] = []; for (var i = 0; i < length; i++) { r[i] = value; } diff --git a/src/vs/base/test/common/event.test.ts b/src/vs/base/test/common/event.test.ts index 35bae3206a961..b042b60fe8354 100644 --- a/src/vs/base/test/common/event.test.ts +++ b/src/vs/base/test/common/event.test.ts @@ -71,7 +71,7 @@ suite('Event', function () { // unhook listener while (bucket.length) { - bucket.pop().dispose(); + bucket.pop()!.dispose(); } // noop diff --git a/src/vs/base/test/common/history.test.ts b/src/vs/base/test/common/history.test.ts index b5d274656fb85..650b04f3a5670 100644 --- a/src/vs/base/test/common/history.test.ts +++ b/src/vs/base/test/common/history.test.ts @@ -118,7 +118,7 @@ suite('History Navigator', () => { historyNavigator.first(); if (historyNavigator.current()) { do { - result.push(historyNavigator.current()); + result.push(historyNavigator.current()!); } while (historyNavigator.next()); } return result; diff --git a/src/vs/base/test/common/keyCodes.test.ts b/src/vs/base/test/common/keyCodes.test.ts index bc746461f941b..a45f859760901 100644 --- a/src/vs/base/test/common/keyCodes.test.ts +++ b/src/vs/base/test/common/keyCodes.test.ts @@ -19,7 +19,7 @@ suite('keyCodes', () => { testBinaryEncoding(expected, k, OperatingSystem.Macintosh); } - test(null, 0); + test(null!, 0); test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter), KeyCode.Enter); test(new SimpleKeybinding(true, false, false, false, KeyCode.Enter), KeyMod.WinCtrl | KeyCode.Enter); test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyCode.Enter); @@ -61,7 +61,7 @@ suite('keyCodes', () => { testBinaryEncoding(expected, k, OS); } - test(null, 0); + test(null!, 0); test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter), KeyCode.Enter); test(new SimpleKeybinding(false, false, false, true, KeyCode.Enter), KeyMod.WinCtrl | KeyCode.Enter); test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyCode.Enter); diff --git a/src/vs/base/test/common/map.test.ts b/src/vs/base/test/common/map.test.ts index 25c41d54daab6..c179bdb34dbb0 100644 --- a/src/vs/base/test/common/map.test.ts +++ b/src/vs/base/test/common/map.test.ts @@ -140,7 +140,7 @@ suite('Map', () => { assert.strictEqual(cache.size, 5); assert.deepStrictEqual(cache.keys(), [3, 4, 5, 6, 7]); let values: number[] = []; - [3, 4, 5, 6, 7].forEach(key => values.push(cache.get(key))); + [3, 4, 5, 6, 7].forEach(key => values.push(cache.get(key)!)); assert.deepStrictEqual(values, [3, 4, 5, 6, 7]); }); @@ -155,7 +155,7 @@ suite('Map', () => { cache.peek(4); assert.deepStrictEqual(cache.keys(), [1, 2, 4, 5, 3]); let values: number[] = []; - [1, 2, 3, 4, 5].forEach(key => values.push(cache.get(key))); + [1, 2, 3, 4, 5].forEach(key => values.push(cache.get(key)!)); assert.deepStrictEqual(values, [1, 2, 3, 4, 5]); }); @@ -177,7 +177,7 @@ suite('Map', () => { assert.deepEqual(cache.size, 15); let values: number[] = []; for (let i = 6; i <= 20; i++) { - values.push(cache.get(i)); + values.push(cache.get(i)!); assert.strictEqual(cache.get(i), i); } assert.deepStrictEqual(cache.values(), values); @@ -194,7 +194,7 @@ suite('Map', () => { assert.strictEqual(cache.size, 5); assert.deepStrictEqual(cache.keys(), [7, 8, 9, 10, 11]); let values: number[] = []; - cache.keys().forEach(key => values.push(cache.get(key))); + cache.keys().forEach(key => values.push(cache.get(key)!)); assert.deepStrictEqual(values, [7, 8, 9, 10, 11]); assert.deepStrictEqual(cache.values(), values); }); @@ -588,7 +588,7 @@ suite('Map', () => { test('mapToSerializable / serializableToMap', function () { const map = new Map(); map.set('1', 'foo'); - map.set('2', null); + map.set('2', null!); map.set('3', 'bar'); const map2 = serializableToMap(mapToSerializable(map)); diff --git a/src/vs/base/test/common/octicon.test.ts b/src/vs/base/test/common/octicon.test.ts index 9135c38e1e234..c91055525d28e 100644 --- a/src/vs/base/test/common/octicon.test.ts +++ b/src/vs/base/test/common/octicon.test.ts @@ -8,7 +8,7 @@ import { matchesFuzzyOcticonAware, parseOcticons } from 'vs/base/common/octicon' export interface IOcticonFilter { // Returns null if word doesn't match. - (query: string, target: { text: string, octiconOffsets?: number[] }): IMatch[]; + (query: string, target: { text: string, octiconOffsets?: number[] }): IMatch[] | null; } function filterOk(filter: IOcticonFilter, word: string, target: { text: string, octiconOffsets?: number[] }, highlights?: { start: number; end: number; }[]) { diff --git a/src/vs/base/test/common/strings.test.ts b/src/vs/base/test/common/strings.test.ts index 2e8ee07797bf1..3e4a5f65ff6b3 100644 --- a/src/vs/base/test/common/strings.test.ts +++ b/src/vs/base/test/common/strings.test.ts @@ -320,7 +320,7 @@ suite('Strings', () => { }); test('fuzzyContains', () => { - assert.ok(!strings.fuzzyContains(void 0, null)); + assert.ok(!strings.fuzzyContains(undefined!, null!)); assert.ok(strings.fuzzyContains('hello world', 'h')); assert.ok(!strings.fuzzyContains('hello world', 'q')); assert.ok(strings.fuzzyContains('hello world', 'hw')); diff --git a/src/vs/base/test/common/uri.test.ts b/src/vs/base/test/common/uri.test.ts index 77351bee75e2b..44b26dfe7b103 100644 --- a/src/vs/base/test/common/uri.test.ts +++ b/src/vs/base/test/common/uri.test.ts @@ -91,9 +91,9 @@ suite('URI', () => { test('with, identity', () => { let uri = URI.parse('foo:bar/path'); - let uri2 = uri.with(null); + let uri2 = uri.with(null!); assert.ok(uri === uri2); - uri2 = uri.with(undefined); + uri2 = uri.with(undefined!); assert.ok(uri === uri2); uri2 = uri.with({}); assert.ok(uri === uri2); diff --git a/src/vs/base/test/node/config.test.ts b/src/vs/base/test/node/config.test.ts index ee4f4e38c74ec..5a146c33db82a 100644 --- a/src/vs/base/test/node/config.test.ts +++ b/src/vs/base/test/node/config.test.ts @@ -141,7 +141,7 @@ suite('Config', () => { testFile('config', 'config.json').then(res => { fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }'); - let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile, { changeBufferDelay: 100, onError: console.error, defaultConfig: void 0 }); + let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile, { changeBufferDelay: 100, onError: console.error, defaultConfig: undefined! }); watcher.getConfig(); // ensure we are in sync fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "changed" }'); diff --git a/src/vs/base/test/node/extfs/extfs.test.ts b/src/vs/base/test/node/extfs/extfs.test.ts index 4031d3080da46..acac894282170 100644 --- a/src/vs/base/test/node/extfs/extfs.test.ts +++ b/src/vs/base/test/node/extfs/extfs.test.ts @@ -38,7 +38,7 @@ function toReadable(value: string, throwError?: boolean): Readable { this.emit('error', new Error(readError)); } - let res: string; + let res!: string; let canPush = true; while (canPush && (res = stringChunks[counter++])) { canPush = this.push(res); @@ -96,14 +96,14 @@ suite('Extfs', () => { return done(error); } - assert.ok(!statAndIsLink.isSymbolicLink); + assert.ok(!statAndIsLink!.isSymbolicLink); extfs.statLink(symbolicLink, (error, statAndIsLink) => { if (error) { return done(error); } - assert.ok(statAndIsLink.isSymbolicLink); + assert.ok(statAndIsLink!.isSymbolicLink); extfs.delSync(directory); done(); }); @@ -258,7 +258,7 @@ suite('Extfs', () => { assert.ok(fs.existsSync(newDir)); - extfs.writeFileAndFlush(testFile, 'Hello World', null, error => { + extfs.writeFileAndFlush(testFile, 'Hello World', null!, error => { if (error) { return done(error); } @@ -267,7 +267,7 @@ suite('Extfs', () => { const largeString = (new Array(100 * 1024)).join('Large String\n'); - extfs.writeFileAndFlush(testFile, largeString, null, error => { + extfs.writeFileAndFlush(testFile, largeString, null!, error => { if (error) { return done(error); } @@ -293,7 +293,7 @@ suite('Extfs', () => { assert.ok(fs.existsSync(newDir)); - extfs.writeFileAndFlush(testFile, toReadable('Hello World'), null, error => { + extfs.writeFileAndFlush(testFile, toReadable('Hello World'), null!, error => { if (error) { return done(error); } @@ -302,7 +302,7 @@ suite('Extfs', () => { const largeString = (new Array(100 * 1024)).join('Large String\n'); - extfs.writeFileAndFlush(testFile, toReadable(largeString), null, error => { + extfs.writeFileAndFlush(testFile, toReadable(largeString), null!, error => { if (error) { return done(error); } @@ -329,7 +329,7 @@ suite('Extfs', () => { assert.ok(fs.existsSync(newDir)); - extfs.writeFileAndFlush(testFile, fs.createReadStream(sourceFile), null, error => { + extfs.writeFileAndFlush(testFile, fs.createReadStream(sourceFile), null!, error => { if (error) { return done(error); } @@ -356,7 +356,7 @@ suite('Extfs', () => { fs.mkdirSync(testFile); // this will trigger an error because testFile is now a directory! - extfs.writeFileAndFlush(testFile, 'Hello World', null, error => { + extfs.writeFileAndFlush(testFile, 'Hello World', null!, error => { if (!error) { return done(new Error('Expected error for writing to readonly file')); } @@ -382,7 +382,7 @@ suite('Extfs', () => { fs.mkdirSync(testFile); // this will trigger an error because testFile is now a directory! const readable = toReadable('Hello World'); - extfs.writeFileAndFlush(testFile, readable, null, error => { + extfs.writeFileAndFlush(testFile, readable, null!, error => { if (!error || (error).code !== 'EISDIR') { return done(new Error('Expected EISDIR error for writing to folder but got: ' + (error ? (error).code : 'no error'))); } @@ -408,7 +408,7 @@ suite('Extfs', () => { assert.ok(fs.existsSync(newDir)); - extfs.writeFileAndFlush(testFile, toReadable('Hello World', true /* throw error */), null, error => { + extfs.writeFileAndFlush(testFile, toReadable('Hello World', true /* throw error */), null!, error => { if (!error || error.message !== readError) { return done(new Error('Expected error for writing to folder')); } @@ -438,7 +438,7 @@ suite('Extfs', () => { fs.writeFileSync(testFile, ''); fs.chmodSync(testFile, 33060); // make readonly - extfs.writeFileAndFlush(testFile, toReadable('Hello World'), null, error => { + extfs.writeFileAndFlush(testFile, toReadable('Hello World'), null!, error => { if (!error || !((error).code !== 'EACCES' || (error).code !== 'EPERM')) { return done(new Error('Expected EACCES/EPERM error for writing to folder but got: ' + (error ? (error).code : 'no error'))); } @@ -464,7 +464,7 @@ suite('Extfs', () => { fs.mkdirSync(testFile); // this will trigger an error because testFile is now a directory! - extfs.writeFileAndFlush(testFile, fs.createReadStream(sourceFile), null, error => { + extfs.writeFileAndFlush(testFile, fs.createReadStream(sourceFile), null!, error => { if (!error) { return done(new Error('Expected error for writing to folder')); } @@ -487,12 +487,12 @@ suite('Extfs', () => { assert.ok(fs.existsSync(newDir)); - extfs.writeFileAndFlushSync(testFile, 'Hello World', null); + extfs.writeFileAndFlushSync(testFile, 'Hello World', null!); assert.equal(fs.readFileSync(testFile), 'Hello World'); const largeString = (new Array(100 * 1024)).join('Large String\n'); - extfs.writeFileAndFlushSync(testFile, largeString, null); + extfs.writeFileAndFlushSync(testFile, largeString, null!); assert.equal(fs.readFileSync(testFile), largeString); extfs.del(parentDir, os.tmpdir(), done, ignore); @@ -556,7 +556,7 @@ suite('Extfs', () => { } catch (error) { assert.ok(!error); } - assert.ok(realpath); + assert.ok(realpath!); extfs.del(parentDir, os.tmpdir(), done, ignore); }); diff --git a/src/vs/base/test/node/flow.test.ts b/src/vs/base/test/node/flow.test.ts index 7aa79a5019bcb..12b5aea89e077 100644 --- a/src/vs/base/test/node/flow.test.ts +++ b/src/vs/base/test/node/flow.test.ts @@ -430,7 +430,7 @@ suite('Flow', () => { parallel(elements, function (element, callback) { sum += element; - callback(null, element * element); + callback(null!, element * element); }, function (errors, result) { assert.ok(!errors); @@ -449,7 +449,7 @@ suite('Flow', () => { parallel(elements, function (element, callback) { setTimeout(function () { sum += element; - callback(null, element * element); + callback(null!, element * element); }, timeouts.pop()); }, function (errors, result) { assert.ok(!errors); @@ -469,10 +469,10 @@ suite('Flow', () => { parallel(elements, function (element, callback) { setTimeout(function () { if (element === 4) { - callback(new Error('error!'), null); + callback(new Error('error!'), null!); } else { sum += element; - callback(null, element * element); + callback(null!, element * element); } }, timeouts.pop()); }, function (errors, result) { diff --git a/src/vs/base/test/node/glob.test.ts b/src/vs/base/test/node/glob.test.ts index 4f851a4ca4fc0..7b003cc002ba5 100644 --- a/src/vs/base/test/node/glob.test.ts +++ b/src/vs/base/test/node/glob.test.ts @@ -738,24 +738,24 @@ suite('Glob', () => { }); test('falsy expression/pattern', function () { - assert.strictEqual(glob.match(null, 'foo'), false); + assert.strictEqual(glob.match(null!, 'foo'), false); assert.strictEqual(glob.match('', 'foo'), false); - assert.strictEqual(glob.parse(null)('foo'), false); + assert.strictEqual(glob.parse(null!)('foo'), false); assert.strictEqual(glob.parse('')('foo'), false); }); test('falsy path', function () { - assert.strictEqual(glob.parse('foo')(null), false); + assert.strictEqual(glob.parse('foo')(null!), false); assert.strictEqual(glob.parse('foo')(''), false); - assert.strictEqual(glob.parse('**/*.j?')(null), false); + assert.strictEqual(glob.parse('**/*.j?')(null!), false); assert.strictEqual(glob.parse('**/*.j?')(''), false); - assert.strictEqual(glob.parse('**/*.foo')(null), false); + assert.strictEqual(glob.parse('**/*.foo')(null!), false); assert.strictEqual(glob.parse('**/*.foo')(''), false); - assert.strictEqual(glob.parse('**/foo')(null), false); + assert.strictEqual(glob.parse('**/foo')(null!), false); assert.strictEqual(glob.parse('**/foo')(''), false); - assert.strictEqual(glob.parse('{**/baz,**/foo}')(null), false); + assert.strictEqual(glob.parse('{**/baz,**/foo}')(null!), false); assert.strictEqual(glob.parse('{**/baz,**/foo}')(''), false); - assert.strictEqual(glob.parse('{**/*.baz,**/*.foo}')(null), false); + assert.strictEqual(glob.parse('{**/*.baz,**/*.foo}')(null!), false); assert.strictEqual(glob.parse('{**/*.baz,**/*.foo}')(''), false); }); @@ -808,7 +808,7 @@ suite('Glob', () => { }, ['foo', 'bar', 'baz'], [ ['bar/foo', '**/foo/**'], ['foo/bar', '{**/bar/**,**/baz/**}'], - ['bar/nope', null] + ['bar/nope', null!] ]); const siblings = ['baz', 'baz.zip', 'nope']; @@ -817,12 +817,12 @@ suite('Glob', () => { '**/foo/**': { when: '$(basename).zip' }, '**/bar/**': true }, ['bar'], [ - ['bar/foo', null], - ['bar/foo/baz', null], - ['bar/foo/nope', null], + ['bar/foo', null!], + ['bar/foo/baz', null!], + ['bar/foo/nope', null!], ['foo/bar', '**/bar/**'], ], [ - null, + null!, hasSibling, hasSibling ]); @@ -832,7 +832,7 @@ suite('Glob', () => { const parsed = glob.parse(pattern, { trimForExclusions: true }); assert.deepStrictEqual(glob.getBasenameTerms(parsed), basenameTerms); matches.forEach(([text, result], i) => { - assert.strictEqual(parsed(text, null, siblingsFns[i]), result); + assert.strictEqual(parsed(text, null!, siblingsFns[i]), result); }); } @@ -914,7 +914,7 @@ suite('Glob', () => { [nativeSep('bar/foo/bar'), '**/foo/bar/**'], // Not supported // [nativeSep('foo/bar/bar'), '{**/bar/bar/**,**/baz/bar/**}'], - [nativeSep('/foo/bar/nope'), null] + [nativeSep('/foo/bar/nope'), null!] ]); const siblings = ['baz', 'baz.zip', 'nope']; @@ -923,12 +923,12 @@ suite('Glob', () => { '**/foo/123/**': { when: '$(basename).zip' }, '**/bar/123/**': true }, ['*/bar/123'], [ - [nativeSep('bar/foo/123'), null], - [nativeSep('bar/foo/123/baz'), null], - [nativeSep('bar/foo/123/nope'), null], + [nativeSep('bar/foo/123'), null!], + [nativeSep('bar/foo/123/baz'), null!], + [nativeSep('bar/foo/123/nope'), null!], [nativeSep('foo/bar/123'), '**/bar/123/**'], ], [ - null, + null!, hasSibling, hasSibling ]); @@ -938,7 +938,7 @@ suite('Glob', () => { const parsed = glob.parse(pattern, { trimForExclusions: true }); assert.deepStrictEqual(glob.getPathTerms(parsed), pathTerms); matches.forEach(([text, result], i) => { - assert.strictEqual(parsed(text, null, siblingsFns[i]), result); + assert.strictEqual(parsed(text, null!, siblingsFns[i]), result); }); } diff --git a/src/vs/base/test/node/pfs.test.ts b/src/vs/base/test/node/pfs.test.ts index 6edeabd4d58ac..172ef642d5d82 100644 --- a/src/vs/base/test/node/pfs.test.ts +++ b/src/vs/base/test/node/pfs.test.ts @@ -24,7 +24,7 @@ suite('PFS', () => { return pfs.mkdirp(newDir, 493).then(() => { assert.ok(fs.existsSync(newDir)); - return pfs.writeFile(testFile, 'Hello World', null).then(() => { + return pfs.writeFile(testFile, 'Hello World', null!).then(() => { assert.equal(fs.readFileSync(testFile), 'Hello World'); return pfs.del(parentDir, os.tmpdir()); @@ -46,11 +46,11 @@ suite('PFS', () => { assert.ok(fs.existsSync(newDir)); return Promise.all([ - pfs.writeFile(testFile1, 'Hello World 1', null), - pfs.writeFile(testFile2, 'Hello World 2', null), - pfs.writeFile(testFile3, 'Hello World 3', null), - pfs.writeFile(testFile4, 'Hello World 4', null), - pfs.writeFile(testFile5, 'Hello World 5', null) + pfs.writeFile(testFile1, 'Hello World 1', null!), + pfs.writeFile(testFile2, 'Hello World 2', null!), + pfs.writeFile(testFile3, 'Hello World 3', null!), + pfs.writeFile(testFile4, 'Hello World 4', null!), + pfs.writeFile(testFile5, 'Hello World 5', null!) ]).then(() => { assert.equal(fs.readFileSync(testFile1), 'Hello World 1'); assert.equal(fs.readFileSync(testFile2), 'Hello World 2'); diff --git a/src/vs/base/test/node/storage/storage.test.ts b/src/vs/base/test/node/storage/storage.test.ts index 0acbb97461c20..37ff2365a0906 100644 --- a/src/vs/base/test/node/storage/storage.test.ts +++ b/src/vs/base/test/node/storage/storage.test.ts @@ -138,7 +138,7 @@ suite('Storage Library', () => { change.set('foo', void 0); database.fireDidChangeItemsExternal({ items: change }); ok(changes.has('foo')); - equal(storage.get('foo', null), null); + equal(storage.get('foo', null!), null); changes.clear(); // Nothing happens if changing to same value @@ -272,7 +272,7 @@ suite('SQLite Storage Library', () => { }; } - const storage = new SQLiteStorageDatabase(path, options); + const storage = new SQLiteStorageDatabase(path, options!); const items = new Map(); items.set('foo', 'bar'); diff --git a/src/vs/code/test/node/windowsFinder.test.ts b/src/vs/code/test/node/windowsFinder.test.ts index 0c04c5b2cf544..441fd8b7cf59f 100644 --- a/src/vs/code/test/node/windowsFinder.test.ts +++ b/src/vs/code/test/node/windowsFinder.test.ts @@ -25,13 +25,13 @@ function options(custom?: Partial>): I reuseWindow: false, context: OpenContext.CLI, codeSettingsFolder: '_vscode', - workspaceResolver: workspace => { return workspace === testWorkspace ? { id: testWorkspace.id, configPath: workspace.configPath, folders: toWorkspaceFolders([{ path: path.join(fixturesFolder, 'vscode_workspace_1_folder') }, { path: path.join(fixturesFolder, 'vscode_workspace_2_folder') }]) } : null; }, + workspaceResolver: workspace => { return workspace === testWorkspace ? { id: testWorkspace.id, configPath: workspace.configPath, folders: toWorkspaceFolders([{ path: path.join(fixturesFolder, 'vscode_workspace_1_folder') }, { path: path.join(fixturesFolder, 'vscode_workspace_2_folder') }]) } : null!; }, ...custom }; } const vscodeFolderWindow: ISimpleWindow = { lastFocusTime: 1, openedFolderUri: URI.file(path.join(fixturesFolder, 'vscode_folder')) }; -const lastActiveWindow: ISimpleWindow = { lastFocusTime: 3, openedFolderUri: null }; +const lastActiveWindow: ISimpleWindow = { lastFocusTime: 3, openedFolderUri: null! }; const noVscodeFolderWindow: ISimpleWindow = { lastFocusTime: 2, openedFolderUri: URI.file(path.join(fixturesFolder, 'no_vscode_folder')) }; const windows: ISimpleWindow[] = [ vscodeFolderWindow, diff --git a/src/vs/editor/contrib/codeAction/test/codeAction.test.ts b/src/vs/editor/contrib/codeAction/test/codeAction.test.ts index 1332b793420a1..82dd8eb39a5ff 100644 --- a/src/vs/editor/contrib/codeAction/test/codeAction.test.ts +++ b/src/vs/editor/contrib/codeAction/test/codeAction.test.ts @@ -156,7 +156,7 @@ suite('CodeAction', () => { const provider = new class implements CodeActionProvider { provideCodeActions(_model: any, _range: Range, context: CodeActionContext, _token: any): CodeAction[] { return [ - { title: context.only, kind: context.only } + { title: context.only!, kind: context.only } ]; } }; diff --git a/src/vs/editor/contrib/codeAction/test/codeActionModel.test.ts b/src/vs/editor/contrib/codeAction/test/codeActionModel.test.ts index e72c67cced868..86e904b38bee1 100644 --- a/src/vs/editor/contrib/codeAction/test/codeActionModel.test.ts +++ b/src/vs/editor/contrib/codeAction/test/codeActionModel.test.ts @@ -51,7 +51,7 @@ suite('CodeAction', () => { assert.equal(e.trigger.type, 'auto'); assert.ok(e.actions); - e.actions.then(fixes => { + e.actions!.then(fixes => { oracle.dispose(); assert.equal(fixes.length, 1); done(); @@ -88,7 +88,7 @@ suite('CodeAction', () => { const oracle = new CodeActionOracle(editor, markerService, e => { assert.equal(e.trigger.type, 'auto'); assert.ok(e.actions); - e.actions.then(fixes => { + e.actions!.then(fixes => { oracle.dispose(); assert.equal(fixes.length, 1); resolve(undefined); @@ -107,7 +107,7 @@ suite('CodeAction', () => { }); disposables.push(reg); - editor.getModel().setValue('// @ts-check\n2\ncon\n'); + editor.getModel()!.setValue('// @ts-check\n2\ncon\n'); markerService.changeOne('fake', uri, [{ startLineNumber: 3, startColumn: 1, endLineNumber: 3, endColumn: 4, @@ -130,7 +130,7 @@ suite('CodeAction', () => { assert.deepEqual(e.position, { lineNumber: 3, column: 1 }); oracle.dispose(); - resolve(null); + resolve(null!); }, 5); editor.setSelection({ startLineNumber: 1, startColumn: 1, endLineNumber: 4, endColumn: 1 }); diff --git a/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts b/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts index a32458d6abdd5..e975b97024c8a 100644 --- a/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts +++ b/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts @@ -950,7 +950,7 @@ suite('Editor Contrib - Line Comment in mixed modes', () => { this._register(modes.TokenizationRegistry.register(this.getLanguageIdentifier().language, { getInitialState: (): modes.IState => NULL_STATE, - tokenize: undefined, + tokenize: undefined!, tokenize2: (line: string, state: modes.IState): TokenizationResult2 => { let languageId = (/^ /.test(line) ? INNER_LANGUAGE_ID : OUTER_LANGUAGE_ID); diff --git a/src/vs/editor/contrib/find/test/findController.test.ts b/src/vs/editor/contrib/find/test/findController.test.ts index 81f2e6bf157ef..80d94fe719b56 100644 --- a/src/vs/editor/contrib/find/test/findController.test.ts +++ b/src/vs/editor/contrib/find/test/findController.test.ts @@ -65,7 +65,7 @@ suite('FindController', () => { onWillSaveState: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - getInteger: (key: string) => undefined, + getInteger: (key: string) => undefined!, store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, remove: (key) => void 0 } as IStorageService); @@ -94,7 +94,7 @@ suite('FindController', () => { // I select ABC on the first line editor.setSelection(new Selection(1, 1, 1, 4)); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null, editor); + startFindAction.run(null!, editor); assert.deepEqual(findController.getGlobalBufferTerm(), findController.getState().searchString); findController.dispose(); @@ -119,10 +119,10 @@ suite('FindController', () => { let findState = findController.getState(); let nextMatchFindAction = new NextMatchFindAction(); - nextMatchFindAction.run(null, editor); + nextMatchFindAction.run(null!, editor); assert.equal(findState.searchString, 'ABC'); - assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 1, 1, 4]); findController.dispose(); }); @@ -167,7 +167,7 @@ suite('FindController', () => { let nextMatchFindAction = new NextMatchFindAction(); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null, editor); + startFindAction.run(null!, editor); // I type ABC. findState.change({ searchString: 'A' }, true); @@ -175,14 +175,14 @@ suite('FindController', () => { findState.change({ searchString: 'ABC' }, true); // The first ABC is highlighted. - assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 1, 1, 4]); // I hit Esc to exit the Find dialog. findController.closeFindWidget(); findController.hasFocus = false; // The cursor is now at end of the first line, with ABC on that line highlighted. - assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 1, 1, 4]); // I hit delete to remove it and change the text to XYZ. editor.pushUndoStop(); @@ -195,13 +195,13 @@ suite('FindController', () => { // ABC // XYZ // ABC - assert.equal(editor.getModel().getLineContent(1), 'XYZ'); + assert.equal(editor.getModel()!.getLineContent(1), 'XYZ'); // The cursor is at end of the first line. - assert.deepEqual(fromRange(editor.getSelection()), [1, 4, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 4, 1, 4]); // I hit F3 to "Find Next" to find the next occurrence of ABC, but instead it searches for XYZ. - nextMatchFindAction.run(null, editor); + nextMatchFindAction.run(null!, editor); assert.equal(findState.searchString, 'ABC'); assert.equal(findController.hasFocus, false); @@ -223,11 +223,11 @@ suite('FindController', () => { column: 9 }); - nextMatchFindAction.run(null, editor); - assert.deepEqual(fromRange(editor.getSelection()), [1, 26, 1, 29]); + nextMatchFindAction.run(null!, editor); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 26, 1, 29]); - nextMatchFindAction.run(null, editor); - assert.deepEqual(fromRange(editor.getSelection()), [1, 8, 1, 11]); + nextMatchFindAction.run(null!, editor); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 8, 1, 11]); findController.dispose(); }); @@ -247,13 +247,13 @@ suite('FindController', () => { editor.setSelection(new Selection(1, 9, 1, 13)); findController.toggleRegex(); - startFindAction.run(null, editor); + startFindAction.run(null!, editor); - nextMatchFindAction.run(null, editor); - assert.deepEqual(fromRange(editor.getSelection()), [2, 9, 2, 13]); + nextMatchFindAction.run(null!, editor); + assert.deepEqual(fromRange(editor.getSelection()!), [2, 9, 2, 13]); - nextMatchFindAction.run(null, editor); - assert.deepEqual(fromRange(editor.getSelection()), [1, 9, 1, 13]); + nextMatchFindAction.run(null!, editor); + assert.deepEqual(fromRange(editor.getSelection()!), [1, 9, 1, 13]); findController.dispose(); }); @@ -278,8 +278,8 @@ suite('FindController', () => { shouldAnimate: false, updateSearchScope: false }); - nextMatchFindAction.run(null, editor); - startFindReplaceAction.run(null, editor); + nextMatchFindAction.run(null!, editor); + startFindReplaceAction.run(null!, editor); assert.equal(findController.getState().searchString, testRegexString); @@ -325,12 +325,12 @@ suite('FindController', () => { let findController = editor.registerAndInstantiateContribution(TestFindController); let startFindAction = new StartFindAction(); - startFindAction.run(null, editor); + startFindAction.run(null!, editor); findController.getState().change({ searchString: '\\b\\s{3}\\b', replaceString: ' ', isRegex: true }, false); findController.moveToNextMatch(); - assert.deepEqual(editor.getSelections().map(fromRange), [ + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [1, 39, 1, 42] ]); @@ -352,12 +352,12 @@ suite('FindController', () => { let findController = editor.registerAndInstantiateContribution(TestFindController); let startFindAction = new StartFindAction(); - startFindAction.run(null, editor); + startFindAction.run(null!, editor); findController.getState().change({ searchString: '^', replaceString: 'x', isRegex: true }, false); findController.moveToNextMatch(); - assert.deepEqual(editor.getSelections().map(fromRange), [ + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [2, 1, 2, 1] ]); @@ -386,9 +386,9 @@ suite('FindController', () => { editor.setSelection(new Selection(1, 1, 1, 9)); // cmd+f3 - nextSelectionMatchFindAction.run(null, editor); + nextSelectionMatchFindAction.run(null!, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [3, 1, 3, 9] ]); @@ -408,7 +408,7 @@ suite('FindController', () => { let nextSelectionMatchFindAction = new NextSelectionMatchFindAction(); // cmd+f - open find widget - startFindAction.run(null, editor); + startFindAction.run(null!, editor); // toggle regex findController.getState().change({ isRegex: true }, false); @@ -417,9 +417,9 @@ suite('FindController', () => { editor.setSelection(new Selection(1, 1, 1, 9)); // cmd+f3 - nextSelectionMatchFindAction.run(null, editor); + nextSelectionMatchFindAction.run(null!, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [3, 1, 3, 9] ]); @@ -440,7 +440,7 @@ suite('FindController query options persistence', () => { onWillSaveState: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - getInteger: (key: string) => undefined, + getInteger: (key: string) => undefined!, store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, remove: (key) => void 0 } as IStorageService); @@ -459,12 +459,12 @@ suite('FindController query options persistence', () => { let startFindAction = new StartFindAction(); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null, editor); + startFindAction.run(null!, editor); // I type ABC. findState.change({ searchString: 'ABC' }, true); // The second ABC is highlighted as matchCase is true. - assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 2, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [2, 1, 2, 4]); findController.dispose(); }); @@ -486,12 +486,12 @@ suite('FindController query options persistence', () => { let startFindAction = new StartFindAction(); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null, editor); + startFindAction.run(null!, editor); // I type AB. findState.change({ searchString: 'AB' }, true); // The second AB is highlighted as wholeWord is true. - assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 2, 3]); + assert.deepEqual(fromRange(editor.getSelection()!), [2, 1, 2, 3]); findController.dispose(); }); diff --git a/src/vs/editor/contrib/find/test/findModel.test.ts b/src/vs/editor/contrib/find/test/findModel.test.ts index 1e529fb155db3..bd93b102c437a 100644 --- a/src/vs/editor/contrib/find/test/findModel.test.ts +++ b/src/vs/editor/contrib/find/test/findModel.test.ts @@ -54,7 +54,7 @@ suite('FindModel', () => { } function _getFindState(editor: ICodeEditor) { - let model = editor.getModel(); + let model = editor.getModel()!; let currentFindMatches: Range[] = []; let allFindMatches: Range[] = []; @@ -76,8 +76,8 @@ suite('FindModel', () => { }; } - function assertFindState(editor: ICodeEditor, cursor: number[], highlighted: number[], findDecorations: number[][]): void { - assert.deepEqual(fromRange(editor.getSelection()), cursor, 'cursor'); + function assertFindState(editor: ICodeEditor, cursor: number[], highlighted: number[] | null, findDecorations: number[][]): void { + assert.deepEqual(fromRange(editor.getSelection()!), cursor, 'cursor'); let expectedState = { highlighted: highlighted ? [highlighted] : [], @@ -1177,7 +1177,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1191,7 +1191,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1204,7 +1204,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, hi!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, hi!" << endl;'); findModel.replace(); assertFindState( @@ -1216,7 +1216,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hi world again" << endl;'); findModel.replace(); assertFindState( @@ -1227,7 +1227,7 @@ suite('FindModel', () => { [6, 14, 6, 19] ] ); - assert.equal(editor.getModel().getLineContent(8), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "hi world again" << endl;'); findModel.replace(); assertFindState( @@ -1236,7 +1236,7 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hi world, hi!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hi world, hi!" << endl;'); findModel.dispose(); findState.dispose(); @@ -1269,7 +1269,7 @@ suite('FindModel', () => { [11, 10, 11, 13] ] ); - assert.equal(editor.getModel().getLineContent(11), '// blablablaciao'); + assert.equal(editor.getModel()!.getLineContent(11), '// blablablaciao'); findModel.replace(); assertFindState( @@ -1281,7 +1281,7 @@ suite('FindModel', () => { [11, 11, 11, 14] ] ); - assert.equal(editor.getModel().getLineContent(11), '// ciaoblablaciao'); + assert.equal(editor.getModel()!.getLineContent(11), '// ciaoblablaciao'); findModel.replace(); assertFindState( @@ -1292,7 +1292,7 @@ suite('FindModel', () => { [11, 12, 11, 15] ] ); - assert.equal(editor.getModel().getLineContent(11), '// ciaociaoblaciao'); + assert.equal(editor.getModel()!.getLineContent(11), '// ciaociaoblaciao'); findModel.replace(); assertFindState( @@ -1301,7 +1301,7 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(11), '// ciaociaociaociao'); + assert.equal(editor.getModel()!.getLineContent(11), '// ciaociaociaociao'); findModel.dispose(); findState.dispose(); @@ -1338,7 +1338,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, Hello!" << endl;'); findModel.replaceAll(); assertFindState( @@ -1347,9 +1347,9 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hi world, hi!" << endl;'); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hi world again" << endl;'); - assert.equal(editor.getModel().getLineContent(8), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hi world, hi!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "hi world again" << endl;'); findModel.dispose(); findState.dispose(); @@ -1388,10 +1388,10 @@ suite('FindModel', () => { [9, 1, 9, 3] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, Hello!" << endl;'); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hello world again" << endl;'); - assert.equal(editor.getModel().getLineContent(8), ' cout << "Hello world again" << endl;'); - assert.equal(editor.getModel().getLineContent(9), ' cout << "helloworld again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hello world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "Hello world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(9), ' cout << "helloworld again" << endl;'); findModel.dispose(); findState.dispose(); @@ -1420,7 +1420,7 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(11), '// ciaociaociaociao'); + assert.equal(editor.getModel()!.getLineContent(11), '// ciaociaociaociao'); findModel.dispose(); findState.dispose(); @@ -1449,10 +1449,10 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(11), '// <'); - assert.equal(editor.getModel().getLineContent(12), '\t><'); - assert.equal(editor.getModel().getLineContent(13), '\t><'); - assert.equal(editor.getModel().getLineContent(14), '\t>ciao'); + assert.equal(editor.getModel()!.getLineContent(11), '// <'); + assert.equal(editor.getModel()!.getLineContent(12), '\t><'); + assert.equal(editor.getModel()!.getLineContent(13), '\t><'); + assert.equal(editor.getModel()!.getLineContent(14), '\t>ciao'); findModel.dispose(); findState.dispose(); @@ -1481,8 +1481,8 @@ suite('FindModel', () => { [] ); - assert.equal(editor.getModel().getLineContent(2), '#bar "cool.h"'); - assert.equal(editor.getModel().getLineContent(3), '#bar '); + assert.equal(editor.getModel()!.getLineContent(2), '#bar "cool.h"'); + assert.equal(editor.getModel()!.getLineContent(3), '#bar '); findModel.dispose(); findState.dispose(); @@ -1671,7 +1671,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1683,7 +1683,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hi world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hi world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1694,7 +1694,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hi world again" << endl;'); findModel.replace(); assertFindState( @@ -1703,7 +1703,7 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(8), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "hi world again" << endl;'); findModel.dispose(); findState.dispose(); @@ -1742,7 +1742,7 @@ suite('FindModel', () => { ] ); - assert.equal(editor.getModel().getLineContent(8), ' cout << "Hello world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "Hello world again" << endl;'); findModel.replace(); assertFindState( @@ -1754,7 +1754,7 @@ suite('FindModel', () => { [7, 14, 7, 19], ] ); - assert.equal(editor.getModel().getLineContent(8), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "hi world again" << endl;'); findModel.replace(); assertFindState( @@ -1765,7 +1765,7 @@ suite('FindModel', () => { [7, 14, 7, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hi world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hi world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1774,7 +1774,7 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hi world again" << endl;'); findModel.dispose(); findState.dispose(); @@ -1798,9 +1798,9 @@ suite('FindModel', () => { findModel.replaceAll(); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hi world, Hello!" << endl;'); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hi world again" << endl;'); - assert.equal(editor.getModel().getLineContent(8), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hi world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "hi world again" << endl;'); assertFindState( editor, @@ -1841,7 +1841,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1853,7 +1853,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hilo world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hilo world, Hello!" << endl;'); findModel.replace(); assertFindState( @@ -1864,7 +1864,7 @@ suite('FindModel', () => { [8, 14, 8, 19] ] ); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hilo world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hilo world again" << endl;'); findModel.replace(); assertFindState( @@ -1873,7 +1873,7 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(8), ' cout << "hilo world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "hilo world again" << endl;'); findModel.dispose(); findState.dispose(); @@ -1898,10 +1898,10 @@ suite('FindModel', () => { findModel.replaceAll(); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello girl, Hello!" << endl;'); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hello girl again" << endl;'); - assert.equal(editor.getModel().getLineContent(8), ' cout << "Hello girl again" << endl;'); - assert.equal(editor.getModel().getLineContent(9), ' cout << "hellogirl again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello girl, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hello girl again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "Hello girl again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(9), ' cout << "hellogirl again" << endl;'); assertFindState( editor, @@ -1931,8 +1931,8 @@ suite('FindModel', () => { findModel.replaceAll(); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hello girl, Hello!" << endl;'); - assert.equal(editor.getModel().getLineContent(8), ' cout << "Hello girl again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hello girl, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << "Hello girl again" << endl;'); assertFindState( editor, @@ -1969,9 +1969,9 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << " world, !" << endl;'); - assert.equal(editor.getModel().getLineContent(7), ' cout << " world again" << endl;'); - assert.equal(editor.getModel().getLineContent(8), ' cout << " world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << " world, !" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << " world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(8), ' cout << " world again" << endl;'); findModel.dispose(); findState.dispose(); @@ -2023,9 +2023,9 @@ suite('FindModel', () => { null, [] ); - assert.equal(editor.getModel().getLineContent(6), ' cout << "hi world, Hello!" << endl;'); - assert.equal(editor.getModel().getLineContent(7), ' cout << "hi world again" << endl;'); - assert.equal(editor.getModel().getLineContent(9), ' cout << "hiworld again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(6), ' cout << "hi world, Hello!" << endl;'); + assert.equal(editor.getModel()!.getLineContent(7), ' cout << "hi world again" << endl;'); + assert.equal(editor.getModel()!.getLineContent(9), ' cout << "hiworld again" << endl;'); findModel.dispose(); findState.dispose(); diff --git a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts index 793029d38e560..569d2dfdd553f 100644 --- a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts +++ b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts @@ -21,18 +21,18 @@ suite('Editor Contrib - Line Operations', () => { 'omicron', 'beta', 'alpha' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let sortLinesAscendingAction = new SortLinesAscendingAction(); editor.setSelection(new Selection(1, 1, 3, 5)); - sortLinesAscendingAction.run(null, editor); + sortLinesAscendingAction.run(null!, editor); assert.deepEqual(model.getLinesContent(), [ 'alpha', 'beta', 'omicron' ]); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 3, 7).toString()); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 3, 7).toString()); }); }); @@ -46,12 +46,12 @@ suite('Editor Contrib - Line Operations', () => { 'omicron', 'beta', 'alpha' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let sortLinesAscendingAction = new SortLinesAscendingAction(); editor.setSelections([new Selection(1, 1, 3, 5), new Selection(5, 1, 7, 5)]); - sortLinesAscendingAction.run(null, editor); + sortLinesAscendingAction.run(null!, editor); assert.deepEqual(model.getLinesContent(), [ 'alpha', 'beta', @@ -65,7 +65,7 @@ suite('Editor Contrib - Line Operations', () => { new Selection(1, 1, 3, 7), new Selection(5, 1, 7, 7) ]; - editor.getSelections().forEach((actualSelection, index) => { + editor.getSelections()!.forEach((actualSelection, index) => { assert.deepEqual(actualSelection.toString(), expectedSelections[index].toString()); }); }); @@ -79,18 +79,18 @@ suite('Editor Contrib - Line Operations', () => { 'alpha', 'beta', 'omicron' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let sortLinesDescendingAction = new SortLinesDescendingAction(); editor.setSelection(new Selection(1, 1, 3, 7)); - sortLinesDescendingAction.run(null, editor); + sortLinesDescendingAction.run(null!, editor); assert.deepEqual(model.getLinesContent(), [ 'omicron', 'beta', 'alpha' ]); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 3, 5).toString()); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 3, 5).toString()); }); }); @@ -104,12 +104,12 @@ suite('Editor Contrib - Line Operations', () => { 'alpha', 'beta', 'omicron' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let sortLinesDescendingAction = new SortLinesDescendingAction(); editor.setSelections([new Selection(1, 1, 3, 7), new Selection(5, 1, 7, 7)]); - sortLinesDescendingAction.run(null, editor); + sortLinesDescendingAction.run(null!, editor); assert.deepEqual(model.getLinesContent(), [ 'omicron', 'beta', @@ -123,7 +123,7 @@ suite('Editor Contrib - Line Operations', () => { new Selection(1, 1, 3, 5), new Selection(5, 1, 7, 5) ]; - editor.getSelections().forEach((actualSelection, index) => { + editor.getSelections()!.forEach((actualSelection, index) => { assert.deepEqual(actualSelection.toString(), expectedSelections[index].toString()); }); }); @@ -138,16 +138,16 @@ suite('Editor Contrib - Line Operations', () => { 'one', 'two', 'three' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let deleteAllLeftAction = new DeleteAllLeftAction(); editor.setSelection(new Selection(1, 2, 1, 2)); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(1), 'ne', '001'); editor.setSelections([new Selection(2, 2, 2, 2), new Selection(3, 2, 3, 2)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(2), 'wo', '002'); assert.equal(model.getLineContent(3), 'hree', '003'); }); @@ -159,21 +159,21 @@ suite('Editor Contrib - Line Operations', () => { 'one', 'two', 'three' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let deleteAllLeftAction = new DeleteAllLeftAction(); editor.setSelection(new Selection(2, 1, 2, 1)); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(1), 'onetwo', '001'); editor.setSelections([new Selection(1, 1, 1, 1), new Selection(2, 1, 2, 1)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLinesContent()[0], 'onetwothree'); assert.equal(model.getLinesContent().length, 1); editor.setSelection(new Selection(1, 1, 1, 1)); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLinesContent()[0], 'onetwothree'); }); }); @@ -187,8 +187,8 @@ suite('Editor Contrib - Line Operations', () => { 'my wife doesnt believe in me', 'nonononono', 'bitconneeeect' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let deleteAllLeftAction = new DeleteAllLeftAction(); const beforeSecondWasoSelection = new Selection(3, 5, 3, 5); @@ -198,7 +198,7 @@ suite('Editor Contrib - Line Operations', () => { editor.setSelections([beforeSecondWasoSelection, endOfBCCSelection, endOfNonono]); let selections; - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); selections = editor.getSelections(); assert.equal(model.getLineContent(2), ''); @@ -226,7 +226,7 @@ suite('Editor Contrib - Line Operations', () => { selections[2].endColumn ], [5, 1, 5, 1]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); selections = editor.getSelections(); assert.equal(model.getLineContent(1), 'hi my name is Carlos Matos waso waso'); @@ -259,28 +259,28 @@ suite('Editor Contrib - Line Operations', () => { 'hola', 'world', 'hello world', - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let deleteAllLeftAction = new DeleteAllLeftAction(); editor.setSelections([new Selection(1, 2, 1, 2), new Selection(1, 4, 1, 4)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(1), 'lo', '001'); editor.setSelections([new Selection(2, 2, 2, 2), new Selection(2, 4, 2, 5)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(2), 'ord', '002'); editor.setSelections([new Selection(3, 2, 3, 5), new Selection(3, 7, 3, 7)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(3), 'world', '003'); editor.setSelections([new Selection(4, 3, 4, 3), new Selection(4, 5, 5, 4)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(4), 'lljour', '004'); editor.setSelections([new Selection(5, 3, 6, 3), new Selection(6, 5, 7, 5), new Selection(7, 7, 7, 7)]); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(5), 'horlworld', '005'); }); }); @@ -291,8 +291,8 @@ suite('Editor Contrib - Line Operations', () => { 'one', 'two', 'three' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let deleteAllLeftAction = new DeleteAllLeftAction(); editor.setSelection(new Selection(1, 1, 1, 1)); @@ -301,7 +301,7 @@ suite('Editor Contrib - Line Operations', () => { assert.equal(model.getLineContent(1), 'Typing some text here on line one'); assert.deepEqual(editor.getSelection(), new Selection(1, 31, 1, 31)); - deleteAllLeftAction.run(null, editor); + deleteAllLeftAction.run(null!, editor); assert.equal(model.getLineContent(1), 'one'); assert.deepEqual(editor.getSelection(), new Selection(1, 1, 1, 1)); @@ -327,34 +327,34 @@ suite('Editor Contrib - Line Operations', () => { '', '', 'hello world' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let joinLinesAction = new JoinLinesAction(); editor.setSelection(new Selection(1, 2, 1, 2)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hello world', '001'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 6, 1, 6).toString(), '002'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 6, 1, 6).toString(), '002'); editor.setSelection(new Selection(2, 2, 2, 2)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(2), 'hello world', '003'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 7, 2, 7).toString(), '004'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 7, 2, 7).toString(), '004'); editor.setSelection(new Selection(3, 2, 3, 2)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(3), 'hello world', '005'); - assert.deepEqual(editor.getSelection().toString(), new Selection(3, 7, 3, 7).toString(), '006'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(3, 7, 3, 7).toString(), '006'); editor.setSelection(new Selection(4, 2, 5, 3)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(4), 'hello world', '007'); - assert.deepEqual(editor.getSelection().toString(), new Selection(4, 2, 4, 8).toString(), '008'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 2, 4, 8).toString(), '008'); editor.setSelection(new Selection(5, 1, 7, 3)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(5), 'hello world', '009'); - assert.deepEqual(editor.getSelection().toString(), new Selection(5, 1, 5, 3).toString(), '010'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(5, 1, 5, 3).toString(), '010'); }); }); @@ -363,15 +363,15 @@ suite('Editor Contrib - Line Operations', () => { [ 'hello', 'world' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let joinLinesAction = new JoinLinesAction(); editor.setSelection(new Selection(2, 1, 2, 1)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hello', '001'); assert.equal(model.getLineContent(2), 'world', '002'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 6, 2, 6).toString(), '003'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 6, 2, 6).toString(), '003'); }); }); @@ -389,8 +389,8 @@ suite('Editor Contrib - Line Operations', () => { '', '', 'hello world' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let joinLinesAction = new JoinLinesAction(); editor.setSelections([ @@ -403,9 +403,9 @@ suite('Editor Contrib - Line Operations', () => { new Selection(10, 1, 10, 1) ]); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLinesContent().join('\n'), 'hello world\nhello world\nhello world\nhello world\n\nhello world', '001'); - assert.deepEqual(editor.getSelections().toString(), [ + assert.deepEqual(editor.getSelections()!.toString(), [ /** primary cursor */ new Selection(3, 4, 3, 8), new Selection(1, 6, 1, 6), @@ -415,7 +415,7 @@ suite('Editor Contrib - Line Operations', () => { ].toString(), '002'); /** primary cursor */ - assert.deepEqual(editor.getSelection().toString(), new Selection(3, 4, 3, 8).toString(), '003'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(3, 4, 3, 8).toString(), '003'); }); }); @@ -424,8 +424,8 @@ suite('Editor Contrib - Line Operations', () => { [ 'hello', 'world' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let joinLinesAction = new JoinLinesAction(); editor.setSelection(new Selection(1, 6, 1, 6)); @@ -434,7 +434,7 @@ suite('Editor Contrib - Line Operations', () => { assert.equal(model.getLineContent(1), 'hello my dear'); assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14)); - joinLinesAction.run(null, editor); + joinLinesAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hello my dear world'); assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14)); @@ -452,34 +452,34 @@ suite('Editor Contrib - Line Operations', () => { '', '', ' ', - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let transposeAction = new TransposeAction(); editor.setSelection(new Selection(1, 1, 1, 1)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hello world', '001'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 2, 1, 2).toString(), '002'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 2, 1, 2).toString(), '002'); editor.setSelection(new Selection(1, 6, 1, 6)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hell oworld', '003'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 7, 1, 7).toString(), '004'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 7, 1, 7).toString(), '004'); editor.setSelection(new Selection(1, 12, 1, 12)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hell oworl', '005'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '006'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 2, 2, 2).toString(), '006'); editor.setSelection(new Selection(3, 1, 3, 1)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(3), '', '007'); - assert.deepEqual(editor.getSelection().toString(), new Selection(4, 1, 4, 1).toString(), '008'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 1, 4, 1).toString(), '008'); editor.setSelection(new Selection(4, 2, 4, 2)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(4), ' ', '009'); - assert.deepEqual(editor.getSelection().toString(), new Selection(4, 3, 4, 3).toString(), '010'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 3, 4, 3).toString(), '010'); } ); @@ -494,29 +494,29 @@ suite('Editor Contrib - Line Operations', () => { 'hello world', '', 'hello world' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let transposeAction = new TransposeAction(); editor.setSelection(new Selection(1, 1, 1, 1)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(2), '', '011'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 1).toString(), '012'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 1, 2, 1).toString(), '012'); editor.setSelection(new Selection(3, 6, 3, 6)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(4), 'oworld', '013'); - assert.deepEqual(editor.getSelection().toString(), new Selection(4, 2, 4, 2).toString(), '014'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 2, 4, 2).toString(), '014'); editor.setSelection(new Selection(6, 12, 6, 12)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(7), 'd', '015'); - assert.deepEqual(editor.getSelection().toString(), new Selection(7, 2, 7, 2).toString(), '016'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(7, 2, 7, 2).toString(), '016'); editor.setSelection(new Selection(8, 12, 8, 12)); - transposeAction.run(null, editor); + transposeAction.run(null!, editor); assert.equal(model.getLineContent(8), 'hello world', '019'); - assert.deepEqual(editor.getSelection().toString(), new Selection(8, 12, 8, 12).toString(), '020'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(8, 12, 8, 12).toString(), '020'); } ); }); @@ -526,40 +526,40 @@ suite('Editor Contrib - Line Operations', () => { [ 'hello world', 'öçşğü' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let uppercaseAction = new UpperCaseAction(); let lowercaseAction = new LowerCaseAction(); editor.setSelection(new Selection(1, 1, 1, 12)); - uppercaseAction.run(null, editor); + uppercaseAction.run(null!, editor); assert.equal(model.getLineContent(1), 'HELLO WORLD', '001'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 12).toString(), '002'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 12).toString(), '002'); editor.setSelection(new Selection(1, 1, 1, 12)); - lowercaseAction.run(null, editor); + lowercaseAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hello world', '003'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 12).toString(), '004'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 12).toString(), '004'); editor.setSelection(new Selection(1, 3, 1, 3)); - uppercaseAction.run(null, editor); + uppercaseAction.run(null!, editor); assert.equal(model.getLineContent(1), 'HELLO world', '005'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 3, 1, 3).toString(), '006'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 3, 1, 3).toString(), '006'); editor.setSelection(new Selection(1, 4, 1, 4)); - lowercaseAction.run(null, editor); + lowercaseAction.run(null!, editor); assert.equal(model.getLineContent(1), 'hello world', '007'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 4, 1, 4).toString(), '008'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 4, 1, 4).toString(), '008'); editor.setSelection(new Selection(2, 1, 2, 6)); - uppercaseAction.run(null, editor); + uppercaseAction.run(null!, editor); assert.equal(model.getLineContent(2), 'ÖÇŞĞÜ', '009'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 6).toString(), '010'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 1, 2, 6).toString(), '010'); editor.setSelection(new Selection(2, 1, 2, 6)); - lowercaseAction.run(null, editor); + lowercaseAction.run(null!, editor); assert.equal(model.getLineContent(2), 'öçşğü', '011'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 6).toString(), '012'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 1, 2, 6).toString(), '012'); } ); @@ -567,51 +567,51 @@ suite('Editor Contrib - Line Operations', () => { [ '', ' ' - ], {}, (editor, cursor) => { - let model = editor.getModel(); + ], {}, (editor) => { + let model = editor.getModel()!; let uppercaseAction = new UpperCaseAction(); let lowercaseAction = new LowerCaseAction(); editor.setSelection(new Selection(1, 1, 1, 1)); - uppercaseAction.run(null, editor); + uppercaseAction.run(null!, editor); assert.equal(model.getLineContent(1), '', '013'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 1).toString(), '014'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 1).toString(), '014'); editor.setSelection(new Selection(1, 1, 1, 1)); - lowercaseAction.run(null, editor); + lowercaseAction.run(null!, editor); assert.equal(model.getLineContent(1), '', '015'); - assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 1).toString(), '016'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 1).toString(), '016'); editor.setSelection(new Selection(2, 2, 2, 2)); - uppercaseAction.run(null, editor); + uppercaseAction.run(null!, editor); assert.equal(model.getLineContent(2), ' ', '017'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '018'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 2, 2, 2).toString(), '018'); editor.setSelection(new Selection(2, 2, 2, 2)); - lowercaseAction.run(null, editor); + lowercaseAction.run(null!, editor); assert.equal(model.getLineContent(2), ' ', '019'); - assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '020'); + assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 2, 2, 2).toString(), '020'); } ); }); suite('DeleteAllRightAction', () => { test('should be noop on empty', () => { - withTestCodeEditor([''], {}, (editor, cursor) => { - const model = editor.getModel(); + withTestCodeEditor([''], {}, (editor) => { + const model = editor.getModel()!; const action = new DeleteAllRightAction(); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['']); assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]); editor.setSelection(new Selection(1, 1, 1, 1)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['']); assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]); editor.setSelections([new Selection(1, 1, 1, 1), new Selection(1, 1, 1, 1), new Selection(1, 1, 1, 1)]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['']); assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]); }); @@ -621,22 +621,22 @@ suite('Editor Contrib - Line Operations', () => { withTestCodeEditor([ 'hello', 'world' - ], {}, (editor, cursor) => { - const model = editor.getModel(); + ], {}, (editor) => { + const model = editor.getModel()!; const action = new DeleteAllRightAction(); editor.setSelection(new Selection(1, 2, 1, 5)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['ho', 'world']); assert.deepEqual(editor.getSelections(), [new Selection(1, 2, 1, 2)]); editor.setSelection(new Selection(1, 1, 2, 4)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['ld']); assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]); editor.setSelection(new Selection(1, 1, 1, 3)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['']); assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]); }); @@ -646,17 +646,17 @@ suite('Editor Contrib - Line Operations', () => { withTestCodeEditor([ 'hello', 'world' - ], {}, (editor, cursor) => { - const model = editor.getModel(); + ], {}, (editor) => { + const model = editor.getModel()!; const action = new DeleteAllRightAction(); editor.setSelection(new Selection(1, 3, 1, 3)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['he', 'world']); assert.deepEqual(editor.getSelections(), [new Selection(1, 3, 1, 3)]); editor.setSelection(new Selection(2, 1, 2, 1)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['he', '']); assert.deepEqual(editor.getSelections(), [new Selection(2, 1, 2, 1)]); }); @@ -666,22 +666,22 @@ suite('Editor Contrib - Line Operations', () => { withTestCodeEditor([ 'hello', 'world' - ], {}, (editor, cursor) => { - const model = editor.getModel(); + ], {}, (editor) => { + const model = editor.getModel()!; const action = new DeleteAllRightAction(); editor.setSelection(new Selection(1, 6, 1, 6)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['helloworld']); assert.deepEqual(editor.getSelections(), [new Selection(1, 6, 1, 6)]); editor.setSelection(new Selection(1, 6, 1, 6)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['hello']); assert.deepEqual(editor.getSelections(), [new Selection(1, 6, 1, 6)]); editor.setSelection(new Selection(1, 6, 1, 6)); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['hello']); assert.deepEqual(editor.getSelections(), [new Selection(1, 6, 1, 6)]); }); @@ -692,8 +692,8 @@ suite('Editor Contrib - Line Operations', () => { 'hello', 'there', 'world' - ], {}, (editor, cursor) => { - const model = editor.getModel(); + ], {}, (editor) => { + const model = editor.getModel()!; const action = new DeleteAllRightAction(); editor.setSelections([ @@ -701,34 +701,34 @@ suite('Editor Contrib - Line Operations', () => { new Selection(1, 6, 1, 6), new Selection(3, 4, 3, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['hethere', 'wor']); assert.deepEqual(editor.getSelections(), [ new Selection(1, 3, 1, 3), new Selection(2, 4, 2, 4) ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['he', 'wor']); assert.deepEqual(editor.getSelections(), [ new Selection(1, 3, 1, 3), new Selection(2, 4, 2, 4) ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['hewor']); assert.deepEqual(editor.getSelections(), [ new Selection(1, 3, 1, 3), new Selection(1, 6, 1, 6) ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['he']); assert.deepEqual(editor.getSelections(), [ new Selection(1, 3, 1, 3) ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['he']); assert.deepEqual(editor.getSelections(), [ new Selection(1, 3, 1, 3) @@ -741,8 +741,8 @@ suite('Editor Contrib - Line Operations', () => { 'hello', 'there', 'world' - ], {}, (editor, cursor) => { - const model = editor.getModel(); + ], {}, (editor) => { + const model = editor.getModel()!; const action = new DeleteAllRightAction(); editor.setSelections([ @@ -750,7 +750,7 @@ suite('Editor Contrib - Line Operations', () => { new Selection(1, 6, 1, 6), new Selection(3, 4, 3, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(model.getLinesContent(), ['hethere', 'wor']); assert.deepEqual(editor.getSelections(), [ new Selection(1, 3, 1, 3), @@ -783,8 +783,8 @@ suite('Editor Contrib - Line Operations', () => { editor.setPosition(new Position(lineNumber, column)); let insertLineBeforeAction = new InsertLineBeforeAction(); - insertLineBeforeAction.run(null, editor); - callback(editor.getModel(), cursor); + insertLineBeforeAction.run(null!, editor); + callback(editor.getModel()!, cursor); }); } @@ -824,8 +824,8 @@ suite('Editor Contrib - Line Operations', () => { editor.setPosition(new Position(lineNumber, column)); let insertLineAfterAction = new InsertLineAfterAction(); - insertLineAfterAction.run(null, editor); - callback(editor.getModel(), cursor); + insertLineAfterAction.run(null!, editor); + callback(editor.getModel()!, cursor); }); } @@ -865,11 +865,11 @@ suite('Editor Contrib - Line Operations', () => { } ); - withTestCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor) => { let indentLinesAction = new IndentLinesAction(); editor.setPosition(new Position(1, 2)); - indentLinesAction.run(null, editor); + indentLinesAction.run(null!, editor); assert.equal(model.getLineContent(1), '\tfunction baz() {'); assert.deepEqual(editor.getSelection(), new Selection(1, 3, 1, 3)); @@ -887,14 +887,14 @@ suite('Editor Contrib - Line Operations', () => { 'too', 'c', ]; - withTestCodeEditor(TEXT, {}, (editor, cursor) => { + withTestCodeEditor(TEXT, {}, (editor) => { editor.setSelections([ new Selection(2, 4, 2, 4), new Selection(2, 8, 2, 8), new Selection(3, 4, 3, 4), ]); const deleteLinesAction = new DeleteLinesAction(); - deleteLinesAction.run(null, editor); + deleteLinesAction.run(null!, editor); assert.equal(editor.getValue(), 'a\nc'); }); diff --git a/src/vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts b/src/vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts index 2abfe4c7de26f..1c7da6e5d6649 100644 --- a/src/vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts +++ b/src/vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts @@ -330,7 +330,7 @@ suite('Editor contrib - Move Lines Command honors Indentation Rules', () => { test('move line should still work as before if there is no indentation rules', () => { testMoveLinesUpWithIndentCommand( - null, + null!, [ 'if (true) {', ' var task = new Task(() => {', diff --git a/src/vs/editor/contrib/multicursor/test/multicursor.test.ts b/src/vs/editor/contrib/multicursor/test/multicursor.test.ts index 83f05dd1534f4..5629cc79a002a 100644 --- a/src/vs/editor/contrib/multicursor/test/multicursor.test.ts +++ b/src/vs/editor/contrib/multicursor/test/multicursor.test.ts @@ -24,7 +24,7 @@ suite('Multicursor', () => { let addCursorUpAction = new InsertCursorAbove(); editor.setSelection(new Selection(2, 1, 2, 1)); - addCursorUpAction.run(null, editor, {}); + addCursorUpAction.run(null!, editor, {}); assert.equal(cursor.getSelections().length, 2); editor.trigger('test', Handler.Paste, { @@ -35,8 +35,8 @@ suite('Multicursor', () => { ] }); // cursorCommand(cursor, H.Paste, { text: '1\n2' }); - assert.equal(editor.getModel().getLineContent(1), '1abc'); - assert.equal(editor.getModel().getLineContent(2), '2def'); + assert.equal(editor.getModel()!.getLineContent(1), '1abc'); + assert.equal(editor.getModel()!.getLineContent(2), '2def'); }); }); @@ -45,7 +45,7 @@ suite('Multicursor', () => { 'abc' ], {}, (editor, cursor) => { let addCursorDownAction = new InsertCursorBelow(); - addCursorDownAction.run(null, editor, {}); + addCursorDownAction.run(null!, editor, {}); assert.equal(cursor.getSelections().length, 1); }); }); @@ -65,7 +65,7 @@ suite('Multicursor selection', () => { onWillSaveState: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - getInteger: (key: string) => undefined, + getInteger: (key: string) => undefined!, store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, remove: (key) => void 0 } as IStorageService); @@ -83,8 +83,8 @@ suite('Multicursor selection', () => { editor.setSelection(new Selection(2, 9, 2, 16)); - selectHighlightsAction.run(null, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + selectHighlightsAction.run(null!, editor); + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [2, 9, 2, 16], [1, 9, 1, 16], [3, 9, 3, 16], @@ -92,7 +92,7 @@ suite('Multicursor selection', () => { editor.trigger('test', 'removeSecondaryCursors', null); - assert.deepEqual(fromRange(editor.getSelection()), [2, 9, 2, 16]); + assert.deepEqual(fromRange(editor.getSelection()!), [2, 9, 2, 16]); multiCursorSelectController.dispose(); findController.dispose(); @@ -114,8 +114,8 @@ suite('Multicursor selection', () => { editor.setSelection(new Selection(1, 1, 1, 1)); findController.getState().change({ searchString: 'some+thing', isRegex: true, isRevealed: true }, false); - selectHighlightsAction.run(null, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + selectHighlightsAction.run(null!, editor); + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [1, 1, 1, 10], [2, 1, 2, 11], [3, 1, 3, 12], @@ -147,15 +147,15 @@ suite('Multicursor selection', () => { editor.setSelection(new Selection(2, 1, 3, 4)); - addSelectionToNextFindMatch.run(null, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + addSelectionToNextFindMatch.run(null!, editor); + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [2, 1, 3, 4], [8, 1, 9, 4] ]); editor.trigger('test', 'removeSecondaryCursors', null); - assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 3, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [2, 1, 3, 4]); multiCursorSelectController.dispose(); findController.dispose(); @@ -175,16 +175,16 @@ suite('Multicursor selection', () => { editor.setSelection(new Selection(1, 1, 1, 4)); - addSelectionToNextFindMatch.run(null, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + addSelectionToNextFindMatch.run(null!, editor); + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [1, 1, 1, 4], [1, 4, 1, 7] ]); - addSelectionToNextFindMatch.run(null, editor); - addSelectionToNextFindMatch.run(null, editor); - addSelectionToNextFindMatch.run(null, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + addSelectionToNextFindMatch.run(null!, editor); + addSelectionToNextFindMatch.run(null!, editor); + addSelectionToNextFindMatch.run(null!, editor); + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [1, 1, 1, 4], [1, 4, 1, 7], [2, 1, 2, 4], @@ -193,7 +193,7 @@ suite('Multicursor selection', () => { ]); editor.trigger('test', Handler.Type, { text: 'z' }); - assert.deepEqual(editor.getSelections().map(fromRange), [ + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [1, 2, 1, 2], [1, 3, 1, 3], [2, 2, 2, 2], @@ -224,7 +224,7 @@ suite('Multicursor selection', () => { 'rty' ], { serviceCollection: serviceCollection }, (editor, cursor) => { - editor.getModel().setEOL(EndOfLineSequence.CRLF); + editor.getModel()!.setEOL(EndOfLineSequence.CRLF); let findController = editor.registerAndInstantiateContribution(CommonFindController); let multiCursorSelectController = editor.registerAndInstantiateContribution(MultiCursorSelectionController); @@ -232,15 +232,15 @@ suite('Multicursor selection', () => { editor.setSelection(new Selection(2, 1, 3, 4)); - addSelectionToNextFindMatch.run(null, editor); - assert.deepEqual(editor.getSelections().map(fromRange), [ + addSelectionToNextFindMatch.run(null!, editor); + assert.deepEqual(editor.getSelections()!.map(fromRange), [ [2, 1, 3, 4], [8, 1, 9, 4] ]); editor.trigger('test', 'removeSecondaryCursors', null); - assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 3, 4]); + assert.deepEqual(fromRange(editor.getSelection()!), [2, 1, 3, 4]); multiCursorSelectController.dispose(); findController.dispose(); @@ -277,25 +277,25 @@ suite('Multicursor selection', () => { new Selection(1, 2, 1, 2), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), new Selection(3, 1, 3, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), @@ -316,20 +316,20 @@ suite('Multicursor selection', () => { new Selection(2, 2, 2, 2), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), new Selection(3, 1, 3, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), @@ -350,20 +350,20 @@ suite('Multicursor selection', () => { new Selection(2, 1, 2, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), new Selection(3, 1, 3, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), @@ -385,14 +385,14 @@ suite('Multicursor selection', () => { new Selection(3, 1, 3, 1), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), new Selection(3, 1, 3, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), @@ -414,14 +414,14 @@ suite('Multicursor selection', () => { new Selection(3, 6, 3, 6), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 5, 1, 10), new Selection(2, 5, 2, 10), new Selection(3, 5, 3, 8), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 5, 1, 10), new Selection(2, 5, 2, 10), @@ -443,20 +443,20 @@ suite('Multicursor selection', () => { new Selection(1, 1, 1, 5), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), new Selection(3, 1, 3, 5), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), @@ -464,7 +464,7 @@ suite('Multicursor selection', () => { new Selection(4, 1, 4, 5), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), @@ -473,7 +473,7 @@ suite('Multicursor selection', () => { new Selection(5, 1, 5, 5), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), @@ -501,18 +501,18 @@ suite('Multicursor selection', () => { new Selection(1, 2, 1, 2), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(4, 1, 4, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(4, 1, 4, 4), @@ -527,12 +527,12 @@ suite('Multicursor selection', () => { new Selection(1, 2, 1, 2), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(4, 1, 4, 4), @@ -543,7 +543,7 @@ suite('Multicursor selection', () => { new Selection(1, 1, 1, 4), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(2, 1, 2, 4), @@ -558,14 +558,14 @@ suite('Multicursor selection', () => { new Selection(1, 2, 1, 2), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(4, 1, 4, 4), new Selection(6, 2, 6, 5), ]); - action.run(null, editor); + action.run(null!, editor); assert.deepEqual(editor.getSelections(), [ new Selection(1, 1, 1, 4), new Selection(4, 1, 4, 4), diff --git a/src/vs/editor/contrib/suggest/test/completionModel.test.ts b/src/vs/editor/contrib/suggest/test/completionModel.test.ts index 104a3ea707ceb..0e69a669a781d 100644 --- a/src/vs/editor/contrib/suggest/test/completionModel.test.ts +++ b/src/vs/editor/contrib/suggest/test/completionModel.test.ts @@ -28,7 +28,7 @@ export function createSuggestItem(label: string, overwriteBefore: number, kind = } }; - return new CompletionItem(position, suggestion, container, provider, undefined); + return new CompletionItem(position, suggestion, container, provider, undefined!); } suite('CompletionModel', function () { diff --git a/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts b/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts index c09c285e8bcb9..1cae3b38fe657 100644 --- a/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts +++ b/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts @@ -86,8 +86,8 @@ suite('WordOperations', () => { text, new Position(1000, 1000), ed => cursorWordLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -114,8 +114,8 @@ suite('WordOperations', () => { text, new Position(1000, 1000), ed => cursorWordLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -130,8 +130,8 @@ suite('WordOperations', () => { text, new Position(1, 21), ed => cursorWordLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -145,8 +145,8 @@ suite('WordOperations', () => { text, new Position(1000, 1000), ed => cursorWordStartLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -160,8 +160,8 @@ suite('WordOperations', () => { text, new Position(1000, 1000), ed => cursorWordStartLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -174,8 +174,8 @@ suite('WordOperations', () => { text, new Position(1000, 1000), ed => cursorWordEndLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -194,8 +194,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => cursorWordRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(5, 2)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(5, 2)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -224,8 +224,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => cursorWordRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 50)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 50)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -240,8 +240,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => cursorWordRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 17)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 17)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -256,8 +256,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => moveWordEndRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 50)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 50)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -273,8 +273,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => moveWordStartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 50)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 50)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -288,8 +288,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => moveWordStartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 15)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 15)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -303,8 +303,8 @@ suite('WordOperations', () => { text, new Position(1, 1), ed => moveWordStartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(2, 12)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(2, 12)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -318,7 +318,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setSelection(new Selection(3, 7, 3, 9)); deleteWordLeft(editor); assert.equal(model.getLineContent(3), ' Thd Line🐶'); @@ -334,7 +334,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 1)); deleteWordLeft(editor); assert.equal(model.getLineContent(1), ' \tMy First Line\t '); @@ -350,7 +350,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(3, 11)); deleteWordLeft(editor); assert.equal(model.getLineContent(3), ' Line🐶'); @@ -366,7 +366,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(2, 11)); deleteWordLeft(editor); assert.equal(model.getLineContent(2), '\tMy Line'); @@ -382,7 +382,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 12)); deleteWordLeft(editor); assert.equal(model.getLineContent(1), ' \tMy st Line\t '); @@ -398,7 +398,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setSelection(new Selection(3, 7, 3, 9)); deleteWordRight(editor); assert.equal(model.getLineContent(3), ' Thd Line🐶'); @@ -414,7 +414,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(5, 3)); deleteWordRight(editor); assert.equal(model.getLineContent(5), '1'); @@ -430,7 +430,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(3, 1)); deleteWordRight(editor); assert.equal(model.getLineContent(3), 'Third Line🐶'); @@ -446,7 +446,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(2, 5)); deleteWordRight(editor); assert.equal(model.getLineContent(2), '\tMy Line'); @@ -462,7 +462,7 @@ suite('WordOperations', () => { '', '1', ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 11)); deleteWordRight(editor); assert.equal(model.getLineContent(1), ' \tMy Fi Line\t '); @@ -479,7 +479,7 @@ suite('WordOperations', () => { text, new Position(1000, 10000), ed => deleteWordLeft(ed), - ed => ed.getPosition(), + ed => ed.getPosition()!, ed => ed.getValue().length === 0 ); const actual = serializePipePositions(text, actualStops); @@ -495,7 +495,7 @@ suite('WordOperations', () => { text, new Position(1000, 10000), ed => deleteWordStartLeft(ed), - ed => ed.getPosition(), + ed => ed.getPosition()!, ed => ed.getValue().length === 0 ); const actual = serializePipePositions(text, actualStops); @@ -511,7 +511,7 @@ suite('WordOperations', () => { text, new Position(1000, 10000), ed => deleteWordEndLeft(ed), - ed => ed.getPosition(), + ed => ed.getPosition()!, ed => ed.getValue().length === 0 ); const actual = serializePipePositions(text, actualStops); @@ -523,7 +523,7 @@ suite('WordOperations', () => { '{', '}' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(2, 1)); deleteWordLeft(editor); assert.equal(model.getLineContent(1), '{}'); }); @@ -532,7 +532,7 @@ suite('WordOperations', () => { '{', '}' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(2, 1)); deleteWordStartLeft(editor); assert.equal(model.getLineContent(1), '{}'); }); @@ -541,7 +541,7 @@ suite('WordOperations', () => { '{', '}' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(2, 1)); deleteWordEndLeft(editor); assert.equal(model.getLineContent(1), '{}'); }); @@ -566,7 +566,7 @@ suite('WordOperations', () => { 'public void Add( int x,', ' int y )' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 24)); deleteWordRight(editor); assert.equal(model.getLineContent(1), 'public void Add( int x,int y )', '001'); }); @@ -577,7 +577,7 @@ suite('WordOperations', () => { 'public void Add( int x,', ' int y )' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 24)); deleteWordStartRight(editor); assert.equal(model.getLineContent(1), 'public void Add( int x,int y )', '001'); }); @@ -588,7 +588,7 @@ suite('WordOperations', () => { 'public void Add( int x,', ' int y )' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 24)); deleteWordEndRight(editor); assert.equal(model.getLineContent(1), 'public void Add( int x,int y )', '001'); }); @@ -627,7 +627,7 @@ suite('WordOperations', () => { 'A line with text.', ' And another one' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(1, 18)); deleteWordRight(editor); assert.equal(model.getLineContent(1), 'A line with text.And another one', '001'); }); @@ -638,7 +638,7 @@ suite('WordOperations', () => { 'A line with text.', ' And another one' ], {}, (editor, _) => { - const model = editor.getModel(); + const model = editor.getModel()!; editor.setPosition(new Position(2, 1)); deleteWordLeft(editor); assert.equal(model.getLineContent(1), 'A line with text. And another one', '001'); }); diff --git a/src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts b/src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts index cce3df09f9155..3981c3bf1f154 100644 --- a/src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts +++ b/src/vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts @@ -45,8 +45,8 @@ suite('WordPartOperations', () => { text, new Position(1000, 1000), ed => cursorWordPartLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -59,8 +59,8 @@ suite('WordPartOperations', () => { text, new Position(1000, 1000), ed => cursorWordPartLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -73,8 +73,8 @@ suite('WordPartOperations', () => { text, new Position(1000, 1000), ed => cursorWordPartLeft(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 1)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 1)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -91,8 +91,8 @@ suite('WordPartOperations', () => { text, new Position(1, 1), ed => cursorWordPartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(3, 9)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(3, 9)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -105,8 +105,8 @@ suite('WordPartOperations', () => { text, new Position(1, 1), ed => cursorWordPartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 52)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 52)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -119,8 +119,8 @@ suite('WordPartOperations', () => { text, new Position(1, 1), ed => cursorWordPartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(1, 52)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(1, 52)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -138,8 +138,8 @@ suite('WordPartOperations', () => { text, new Position(1, 1), ed => cursorWordPartRight(ed), - ed => ed.getPosition(), - ed => ed.getPosition().equals(new Position(4, 7)) + ed => ed.getPosition()!, + ed => ed.getPosition()!.equals(new Position(4, 7)) ); const actual = serializePipePositions(text, actualStops); assert.deepEqual(actual, EXPECTED); @@ -152,7 +152,7 @@ suite('WordPartOperations', () => { text, new Position(1, 1000), ed => deleteWordPartLeft(ed), - ed => ed.getPosition(), + ed => ed.getPosition()!, ed => ed.getValue().length === 0 ); const actual = serializePipePositions(text, actualStops); diff --git a/src/vs/editor/standalone/test/browser/simpleServices.test.ts b/src/vs/editor/standalone/test/browser/simpleServices.test.ts index 7154ac5e4f281..160fa02625345 100644 --- a/src/vs/editor/standalone/test/browser/simpleServices.test.ts +++ b/src/vs/editor/standalone/test/browser/simpleServices.test.ts @@ -15,7 +15,7 @@ suite('StandaloneKeybindingService', () => { class TestStandaloneKeybindingService extends StandaloneKeybindingService { public testDispatch(e: IKeyboardEvent): void { - super._dispatch(e, null); + super._dispatch(e, null!); } } @@ -47,7 +47,7 @@ suite('StandaloneKeybindingService', () => { altKey: false, metaKey: false, keyCode: KeyCode.F9, - code: null + code: null! }); assert.ok(commandInvoked, 'command invoked'); 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/configuration/test/common/configurationModels.test.ts b/src/vs/platform/configuration/test/common/configurationModels.test.ts index 6085c98510a4f..032f302804ebb 100644 --- a/src/vs/platform/configuration/test/common/configurationModels.test.ts +++ b/src/vs/platform/configuration/test/common/configurationModels.test.ts @@ -331,12 +331,12 @@ suite('CustomConfigurationModel', () => { assert.deepEqual(testObject.configurationModel.contents, {}); assert.deepEqual(testObject.configurationModel.keys, []); - testObject.parse(null); + testObject.parse(null!); assert.deepEqual(testObject.configurationModel.contents, {}); assert.deepEqual(testObject.configurationModel.keys, []); - testObject.parse(undefined); + testObject.parse(undefined!); assert.deepEqual(testObject.configurationModel.contents, {}); assert.deepEqual(testObject.configurationModel.keys, []); diff --git a/src/vs/platform/contextkey/test/common/contextkey.test.ts b/src/vs/platform/contextkey/test/common/contextkey.test.ts index cec230cc148f5..cb12470e3c287 100644 --- a/src/vs/platform/contextkey/test/common/contextkey.test.ts +++ b/src/vs/platform/contextkey/test/common/contextkey.test.ts @@ -50,10 +50,10 @@ suite('ContextKeyExpr', () => { let key1IsFalse = ContextKeyExpr.equals('key1', false); let key1IsNotTrue = ContextKeyExpr.notEquals('key1', true); - assert.ok(key1IsTrue.normalize().equals(ContextKeyExpr.has('key1'))); - assert.ok(key1IsNotFalse.normalize().equals(ContextKeyExpr.has('key1'))); - assert.ok(key1IsFalse.normalize().equals(ContextKeyExpr.not('key1'))); - assert.ok(key1IsNotTrue.normalize().equals(ContextKeyExpr.not('key1'))); + assert.ok(key1IsTrue.normalize()!.equals(ContextKeyExpr.has('key1'))); + assert.ok(key1IsNotFalse.normalize()!.equals(ContextKeyExpr.has('key1'))); + assert.ok(key1IsFalse.normalize()!.equals(ContextKeyExpr.not('key1'))); + assert.ok(key1IsNotTrue.normalize()!.equals(ContextKeyExpr.not('key1'))); }); test('evaluate', () => { @@ -67,7 +67,7 @@ suite('ContextKeyExpr', () => { function testExpression(expr: string, expected: boolean): void { // console.log(expr + ' ' + expected); let rules = ContextKeyExpr.deserialize(expr); - assert.equal(rules.evaluate(context), expected, expr); + assert.equal(rules!.evaluate(context), expected, expr); } function testBatch(expr: string, value: any): void { testExpression(expr, !!value); diff --git a/src/vs/platform/extensions/test/node/extensionValidator.test.ts b/src/vs/platform/extensions/test/node/extensionValidator.test.ts index 510243ca7133b..f88885d95083a 100644 --- a/src/vs/platform/extensions/test/node/extensionValidator.test.ts +++ b/src/vs/platform/extensions/test/node/extensionValidator.test.ts @@ -27,7 +27,7 @@ suite('Extension Version Validator', () => { }); test('parseVersion', () => { - function assertParseVersion(version: string, hasCaret: boolean, hasGreaterEquals: boolean, majorBase: number, majorMustEqual: boolean, minorBase: number, minorMustEqual: boolean, patchBase: number, patchMustEqual: boolean, preRelease: string): void { + function assertParseVersion(version: string, hasCaret: boolean, hasGreaterEquals: boolean, majorBase: number, majorMustEqual: boolean, minorBase: number, minorMustEqual: boolean, patchBase: number, patchMustEqual: boolean, preRelease: string | null): void { const actual = parseVersion(version); const expected: IParsedVersion = { hasCaret, hasGreaterEquals, majorBase, majorMustEqual, minorBase, minorMustEqual, patchBase, patchMustEqual, preRelease }; diff --git a/src/vs/platform/files/test/files.test.ts b/src/vs/platform/files/test/files.test.ts index 289d61534917b..48780f11e6e6c 100644 --- a/src/vs/platform/files/test/files.test.ts +++ b/src/vs/platform/files/test/files.test.ts @@ -49,8 +49,8 @@ suite('Files', () => { // corner cases assert(testMethod('', '', true)); - assert(!testMethod(null, '', true)); - assert(!testMethod(void 0, '', true)); + assert(!testMethod(null!, '', true)); + assert(!testMethod(undefined!, '', true)); // basics (string) assert(testMethod('/', '/', true)); diff --git a/src/vs/platform/instantiation/test/common/instantiationService.test.ts b/src/vs/platform/instantiation/test/common/instantiationService.test.ts index dbb2685083651..9cddf4e9f6725 100644 --- a/src/vs/platform/instantiation/test/common/instantiationService.test.ts +++ b/src/vs/platform/instantiation/test/common/instantiationService.test.ts @@ -137,7 +137,7 @@ suite('Instantiation Service', () => { test('service collection, cannot overwrite', function () { let collection = new ServiceCollection(); - let result = collection.set(IService1, null); + let result = collection.set(IService1, null!); assert.equal(result, undefined); result = collection.set(IService1, new Service1()); assert.equal(result, null); @@ -145,10 +145,10 @@ suite('Instantiation Service', () => { test('service collection, add/has', function () { let collection = new ServiceCollection(); - collection.set(IService1, null); + collection.set(IService1, null!); assert.ok(collection.has(IService1)); - collection.set(IService2, null); + collection.set(IService2, null!); assert.ok(collection.has(IService1)); assert.ok(collection.has(IService2)); }); 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/keybinding/test/common/keybindingLabels.test.ts b/src/vs/platform/keybinding/test/common/keybindingLabels.test.ts index a0ded747d812f..16e096e564bb4 100644 --- a/src/vs/platform/keybinding/test/common/keybindingLabels.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingLabels.test.ts @@ -10,7 +10,7 @@ import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayo suite('KeybindingLabels', () => { function assertUSLabel(OS: OperatingSystem, keybinding: number, expected: string): void { - const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS); + const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS); assert.equal(usResolvedKeybinding.getLabel(), expected); } @@ -115,7 +115,7 @@ suite('KeybindingLabels', () => { test('Aria label', () => { function assertAriaLabel(OS: OperatingSystem, keybinding: number, expected: string): void { - const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS); + const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS); assert.equal(usResolvedKeybinding.getAriaLabel(), expected); } @@ -125,8 +125,8 @@ suite('KeybindingLabels', () => { }); test('Electron Accelerator label', () => { - function assertElectronAcceleratorLabel(OS: OperatingSystem, keybinding: number, expected: string): void { - const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS); + function assertElectronAcceleratorLabel(OS: OperatingSystem, keybinding: number, expected: string | null): void { + const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS); assert.equal(usResolvedKeybinding.getElectronAccelerator(), expected); } @@ -153,7 +153,7 @@ suite('KeybindingLabels', () => { test('User Settings label', () => { function assertElectronAcceleratorLabel(OS: OperatingSystem, keybinding: number, expected: string): void { - const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS); + const usResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS); assert.equal(usResolvedKeybinding.getUserSettingsLabel(), expected); } diff --git a/src/vs/platform/keybinding/test/common/keybindingResolver.test.ts b/src/vs/platform/keybinding/test/common/keybindingResolver.test.ts index 39970c898033e..4cabf4af10ac6 100644 --- a/src/vs/platform/keybinding/test/common/keybindingResolver.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingResolver.test.ts @@ -21,7 +21,7 @@ function createContext(ctx: any) { suite('KeybindingResolver', () => { function kbItem(keybinding: number, command: string, commandArgs: any, when: ContextKeyExpr, isDefault: boolean): 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, @@ -32,7 +32,7 @@ suite('KeybindingResolver', () => { } function getDispatchStr(runtimeKb: SimpleKeybinding): string { - return USLayoutResolvedKeybinding.getDispatchStr(runtimeKb); + return USLayoutResolvedKeybinding.getDispatchStr(runtimeKb)!; } test('resolve key', function () { @@ -45,7 +45,7 @@ suite('KeybindingResolver', () => { assert.equal(KeybindingResolver.contextMatchesRules(createContext({ bar: 'bz' }), contextRules), false); let resolver = new KeybindingResolver([keybindingItem], []); - assert.equal(resolver.resolve(createContext({ bar: 'baz' }), null, getDispatchStr(runtimeKeybinding)).commandId, 'yes'); + assert.equal(resolver.resolve(createContext({ bar: 'baz' }), null, getDispatchStr(runtimeKeybinding))!.commandId, 'yes'); assert.equal(resolver.resolve(createContext({ bar: 'bz' }), null, getDispatchStr(runtimeKeybinding)), null); }); @@ -57,7 +57,7 @@ suite('KeybindingResolver', () => { let keybindingItem = kbItem(keybinding, 'yes', commandArgs, contextRules, true); let resolver = new KeybindingResolver([keybindingItem], []); - assert.equal(resolver.resolve(createContext({ bar: 'baz' }), null, getDispatchStr(runtimeKeybinding)).commandArgs, commandArgs); + assert.equal(resolver.resolve(createContext({ bar: 'baz' }), null, getDispatchStr(runtimeKeybinding))!.commandArgs, commandArgs); }); test('KeybindingResolver.combine simple 1', function () { @@ -154,7 +154,7 @@ suite('KeybindingResolver', () => { kbItem(KeyCode.KEY_B, 'yes2', null, ContextKeyExpr.equals('2', 'b'), true) ]; let overrides = [ - kbItem(KeyCode.KEY_A, '-yes1', null, null, false) + kbItem(KeyCode.KEY_A, '-yes1', null, null!, false) ]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ @@ -168,7 +168,7 @@ suite('KeybindingResolver', () => { kbItem(KeyCode.KEY_B, 'yes2', null, ContextKeyExpr.equals('2', 'b'), true) ]; let overrides = [ - kbItem(0, '-yes1', null, null, false) + kbItem(0, '-yes1', null, null!, false) ]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ @@ -182,7 +182,7 @@ suite('KeybindingResolver', () => { kbItem(KeyCode.KEY_B, 'yes2', null, ContextKeyExpr.equals('2', 'b'), true) ]; let overrides = [ - kbItem(KeyCode.KEY_A, '-yes1', null, null, false) + kbItem(KeyCode.KEY_A, '-yes1', null, null!, false) ]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ @@ -210,7 +210,7 @@ suite('KeybindingResolver', () => { let key3IsTrue = ContextKeyExpr.equals('key3', true); let key4IsTrue = ContextKeyExpr.equals('key4', true); - assertIsIncluded([key1IsTrue], null); + assertIsIncluded([key1IsTrue], null!); assertIsIncluded([key1IsTrue], []); assertIsIncluded([key1IsTrue], [key1IsTrue]); assertIsIncluded([key1IsTrue], [key1IsNotFalse]); @@ -243,7 +243,7 @@ suite('KeybindingResolver', () => { assertIsNotIncluded([key1IsTrue, key2IsNotFalse], [key4IsTrue]); assertIsNotIncluded([key1IsTrue], [key2IsTrue]); assertIsNotIncluded([], [key2IsTrue]); - assertIsNotIncluded(null, [key2IsTrue]); + assertIsNotIncluded(null!, [key2IsTrue]); }); test('resolve command', function () { @@ -272,7 +272,7 @@ suite('KeybindingResolver', () => { _kbItem( KeyCode.KEY_Z, 'second', - null + null! ), // This one sometimes overwrites first _kbItem( @@ -290,43 +290,43 @@ suite('KeybindingResolver', () => { _kbItem( KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_Y, KeyCode.KEY_Z), 'fifth', - null + null! ), // This one has no keybinding _kbItem( 0, 'sixth', - null + null! ), _kbItem( KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U), 'seventh', - null + null! ), _kbItem( KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K), 'seventh', - null + null! ), _kbItem( KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U), 'uncomment lines', - null + null! ), _kbItem( KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C), 'comment lines', - null + null! ), _kbItem( KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_G, KeyMod.CtrlCmd | KeyCode.KEY_C), 'unreachablechord', - null + null! ), _kbItem( KeyMod.CtrlCmd | KeyCode.KEY_G, 'eleven', - null + null! ) ]; @@ -337,30 +337,30 @@ suite('KeybindingResolver', () => { let lookupResult = resolver.lookupKeybindings(commandId); assert.equal(lookupResult.length, expectedKeys.length, 'Length mismatch @ commandId ' + commandId + '; GOT: ' + JSON.stringify(lookupResult, null, '\t')); for (let i = 0, len = lookupResult.length; i < len; i++) { - const expected = new USLayoutResolvedKeybinding(createKeybinding(expectedKeys[i], OS), OS); + const expected = new USLayoutResolvedKeybinding(createKeybinding(expectedKeys[i], OS)!, OS); - assert.equal(lookupResult[i].resolvedKeybinding.getUserSettingsLabel(), expected.getUserSettingsLabel(), 'value mismatch @ commandId ' + commandId); + assert.equal(lookupResult[i].resolvedKeybinding!.getUserSettingsLabel(), expected.getUserSettingsLabel(), 'value mismatch @ commandId ' + commandId); } }; let testResolve = (ctx: IContext, _expectedKey: number, commandId: string) => { - const expectedKey = createKeybinding(_expectedKey, OS); + const expectedKey = createKeybinding(_expectedKey, OS)!; if (expectedKey.type === KeybindingType.Chord) { let firstPart = getDispatchStr(expectedKey.firstPart); let chordPart = getDispatchStr(expectedKey.chordPart); - let result = resolver.resolve(ctx, null, firstPart); + let result = resolver.resolve(ctx, null, firstPart)!; assert.ok(result !== null, 'Enters chord for ' + commandId); assert.equal(result.commandId, null, 'Enters chord for ' + commandId); assert.equal(result.enterChord, true, 'Enters chord for ' + commandId); - result = resolver.resolve(ctx, firstPart, chordPart); + result = resolver.resolve(ctx, firstPart, chordPart)!; assert.ok(result !== null, 'Enters chord for ' + commandId); assert.equal(result.commandId, commandId, 'Finds chorded command ' + commandId); assert.equal(result.enterChord, false, 'Finds chorded command ' + commandId); } else { - let result = resolver.resolve(ctx, null, getDispatchStr(expectedKey)); + let result = resolver.resolve(ctx, null, getDispatchStr(expectedKey))!; assert.ok(result !== null, 'Finds command ' + commandId); assert.equal(result.commandId, commandId, 'Finds command ' + commandId); assert.equal(result.enterChord, false, 'Finds command ' + commandId); diff --git a/src/vs/platform/markers/test/common/markerService.test.ts b/src/vs/platform/markers/test/common/markerService.test.ts index 0859b964f70cd..2f8607c241ce3 100644 --- a/src/vs/platform/markers/test/common/markerService.test.ts +++ b/src/vs/platform/markers/test/common/markerService.test.ts @@ -160,11 +160,11 @@ suite('Marker Service', () => { let data = randomMarkerData(); let service = new markerService.MarkerService(); - data.message = undefined; + data.message = undefined!; service.changeOne('far', URI.parse('some:uri/path'), [data]); assert.equal(service.read({ owner: 'far' }).length, 0); - data.message = null; + data.message = null!; service.changeOne('far', URI.parse('some:uri/path'), [data]); assert.equal(service.read({ owner: 'far' }).length, 0); diff --git a/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts b/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts index 6f078a234c668..71dfa4603df8f 100644 --- a/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts @@ -80,7 +80,7 @@ suite('AIAdapter', () => { setup(() => { appInsightsMock = new AppInsightsMock(); - adapter = new AppInsightsAppender(prefix, undefined, () => appInsightsMock); + adapter = new AppInsightsAppender(prefix, undefined!, () => appInsightsMock); }); teardown(() => { @@ -101,9 +101,9 @@ suite('AIAdapter', () => { assert.equal(appInsightsMock.events.length, 1); let [first] = appInsightsMock.events; assert.equal(first.name, `${prefix}/testEvent`); - assert.equal(first.properties['first'], '1st'); - assert.equal(first.measurements['second'], '2'); - assert.equal(first.measurements['third'], 1); + assert.equal(first.properties!['first'], '1st'); + assert.equal(first.measurements!['second'], '2'); + assert.equal(first.measurements!['third'], 1); }); test('property limits', () => { @@ -126,9 +126,9 @@ suite('AIAdapter', () => { assert.equal(appInsightsMock.events.length, 1); - for (var prop in appInsightsMock.events[0].properties) { + for (var prop in appInsightsMock.events[0].properties!) { assert(prop.length < 150); - assert(appInsightsMock.events[0].properties[prop].length < 1024); + assert(appInsightsMock.events[0].properties![prop].length < 1024); } }); @@ -138,12 +138,12 @@ suite('AIAdapter', () => { assert.equal(appInsightsMock.events.length, 1); assert.equal(appInsightsMock.events[0].name, `${prefix}/testEvent`); - assert.equal(appInsightsMock.events[0].properties['favoriteColor'], 'blue'); - assert.equal(appInsightsMock.events[0].measurements['likeRed'], 0); - assert.equal(appInsightsMock.events[0].measurements['likeBlue'], 1); - assert.equal(appInsightsMock.events[0].properties['favoriteDate'], date.toISOString()); - assert.equal(appInsightsMock.events[0].properties['favoriteCars'], JSON.stringify(['bmw', 'audi', 'ford'])); - assert.equal(appInsightsMock.events[0].measurements['favoriteNumber'], 1); + assert.equal(appInsightsMock.events[0].properties!['favoriteColor'], 'blue'); + assert.equal(appInsightsMock.events[0].measurements!['likeRed'], 0); + assert.equal(appInsightsMock.events[0].measurements!['likeBlue'], 1); + assert.equal(appInsightsMock.events[0].properties!['favoriteDate'], date.toISOString()); + assert.equal(appInsightsMock.events[0].properties!['favoriteCars'], JSON.stringify(['bmw', 'audi', 'ford'])); + assert.equal(appInsightsMock.events[0].measurements!['favoriteNumber'], 1); }); test('Nested data', () => { @@ -168,12 +168,12 @@ suite('AIAdapter', () => { assert.equal(appInsightsMock.events.length, 1); assert.equal(appInsightsMock.events[0].name, `${prefix}/testEvent`); - assert.equal(appInsightsMock.events[0].properties['window.title'], 'some title'); - assert.equal(appInsightsMock.events[0].measurements['window.measurements.width'], 100); - assert.equal(appInsightsMock.events[0].measurements['window.measurements.height'], 200); + assert.equal(appInsightsMock.events[0].properties!['window.title'], 'some title'); + assert.equal(appInsightsMock.events[0].measurements!['window.measurements.width'], 100); + assert.equal(appInsightsMock.events[0].measurements!['window.measurements.height'], 200); - assert.equal(appInsightsMock.events[0].properties['nestedObj.nestedObj2.nestedObj3'], JSON.stringify({ 'testProperty': 'test' })); - assert.equal(appInsightsMock.events[0].measurements['nestedObj.testMeasurement'], 1); + assert.equal(appInsightsMock.events[0].properties!['nestedObj.nestedObj2.nestedObj3'], JSON.stringify({ 'testProperty': 'test' })); + assert.equal(appInsightsMock.events[0].measurements!['nestedObj.testMeasurement'], 1); }); test('Do not Log Telemetry if log level is not trace', () => { diff --git a/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts b/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts index 193a20bf6f532..9f72874534443 100644 --- a/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts @@ -86,7 +86,7 @@ suite('TelemetryService', () => { test('Disposing', sinon.test(function () { let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ appender: testAppender }, undefined); + let service = new TelemetryService({ appender: testAppender }, undefined!); return service.publicLog('testPrivateEvent').then(() => { assert.equal(testAppender.getEventsCount(), 1); @@ -99,7 +99,7 @@ suite('TelemetryService', () => { // event reporting test('Simple event', sinon.test(function () { let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ appender: testAppender }, undefined); + let service = new TelemetryService({ appender: testAppender }, undefined!); return service.publicLog('testEvent').then(_ => { assert.equal(testAppender.getEventsCount(), 1); @@ -112,7 +112,7 @@ suite('TelemetryService', () => { test('Event with data', sinon.test(function () { let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ appender: testAppender }, undefined); + let service = new TelemetryService({ appender: testAppender }, undefined!); return service.publicLog('testEvent', { 'stringProp': 'property', @@ -140,7 +140,7 @@ suite('TelemetryService', () => { let service = new TelemetryService({ appender: testAppender, commonProperties: Promise.resolve({ foo: 'JA!', get bar() { return Math.random(); } }) - }, undefined); + }, undefined!); return service.publicLog('testEvent').then(_ => { let [first] = testAppender.events; @@ -158,7 +158,7 @@ suite('TelemetryService', () => { let service = new TelemetryService({ appender: testAppender, commonProperties: Promise.resolve({ foo: 'JA!', get bar() { return Math.random(); } }) - }, undefined); + }, undefined!); return service.publicLog('testEvent', { hightower: 'xl', price: 8000 }).then(_ => { let [first] = testAppender.events; @@ -181,7 +181,7 @@ suite('TelemetryService', () => { ['common.instanceId']: 'two', ['common.machineId']: 'three', }) - }, undefined); + }, undefined!); return service.getTelemetryInfo().then(info => { assert.equal(info.sessionId, 'one'); @@ -194,7 +194,7 @@ suite('TelemetryService', () => { test('enableTelemetry on by default', sinon.test(function () { let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ appender: testAppender }, undefined); + let service = new TelemetryService({ appender: testAppender }, undefined!); return service.publicLog('testEvent').then(() => { assert.equal(testAppender.getEventsCount(), 1); @@ -226,7 +226,7 @@ suite('TelemetryService', () => { try { let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); @@ -285,7 +285,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let testError = new Error('test'); @@ -313,7 +313,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let personInfoWithSpaces = settings.personalInfo.slice(0, 2) + ' ' + settings.personalInfo.slice(2); @@ -337,7 +337,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousFilenameError: any = new Error('dangerousFilename'); @@ -369,7 +369,7 @@ suite('TelemetryService', () => { try { let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithoutImportantInfoError: any = new Error(settings.dangerousPathWithoutImportantInfo); @@ -399,7 +399,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithoutImportantInfoError: any = new Error('dangerousPathWithoutImportantInfo'); @@ -429,7 +429,7 @@ suite('TelemetryService', () => { try { let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithImportantInfoError: any = new Error(settings.dangerousPathWithImportantInfo); @@ -462,7 +462,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithImportantInfoError: any = new Error('dangerousPathWithImportantInfo'); @@ -494,7 +494,7 @@ suite('TelemetryService', () => { try { let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithImportantInfoError: any = new Error(settings.dangerousPathWithImportantInfo); @@ -523,7 +523,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithImportantInfoError: any = new Error('dangerousPathWithImportantInfo'); @@ -552,7 +552,7 @@ suite('TelemetryService', () => { try { let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithImportantInfoError: any = new Error(settings.dangerousPathWithImportantInfo); @@ -585,7 +585,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender, piiPaths: [settings.personalInfo + '/resources/app/'] }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let dangerousPathWithImportantInfoError: any = new Error('dangerousPathWithImportantInfo'); @@ -617,7 +617,7 @@ suite('TelemetryService', () => { try { let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let missingModelError: any = new Error(settings.missingModelMessage); @@ -650,7 +650,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let missingModelError: any = new Error('missingModelMessage'); @@ -683,7 +683,7 @@ suite('TelemetryService', () => { try { let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let noSuchFileError: any = new Error(settings.noSuchFileMessage); @@ -720,7 +720,7 @@ suite('TelemetryService', () => { window.onerror = errorStub; let settings = new ErrorTestingSettings(); let testAppender = new TestTelemetryAppender(); - let service = new JoinableTelemetryService({ appender: testAppender }, undefined); + let service = new JoinableTelemetryService({ appender: testAppender }, undefined!); const errorTelemetry = new ErrorTelemetry(service); let noSuchFileError: any = new Error('noSuchFileMessage'); @@ -751,7 +751,7 @@ suite('TelemetryService', () => { test('Telemetry Service sends events when enableTelemetry is on', sinon.test(function () { let testAppender = new TestTelemetryAppender(); - let service = new TelemetryService({ appender: testAppender }, undefined); + let service = new TelemetryService({ appender: testAppender }, undefined!); return service.publicLog('testEvent').then(() => { assert.equal(testAppender.getEventsCount(), 1); @@ -775,20 +775,20 @@ suite('TelemetryService', () => { } as any; }, updateValue(): Promise { - return null; + return null!; }, inspect(key: string) { return { value: getConfigurationValue(this.getValue(), key), default: getConfigurationValue(this.getValue(), key), user: getConfigurationValue(this.getValue(), key), - workspace: null, - workspaceFolder: null + workspace: null!, + workspaceFolder: null! }; }, keys() { return { default: [], user: [], workspace: [], workspaceFolder: [] }; }, onDidChangeConfiguration: emitter.event, - reloadConfiguration(): Promise { return null; }, + reloadConfiguration(): Promise { return null!; }, getConfigurationData() { return null; } }); diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index a90aabedb367f..30bf10f6ce381 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -453,7 +453,7 @@ export class TextEdit { } protected _range: Range; - protected _newText: string; + protected _newText: string | null | undefined; protected _newEol: EndOfLine; get range(): Range { @@ -489,9 +489,9 @@ export class TextEdit { this._newEol = value; } - constructor(range: Range, newText: string) { + constructor(range: Range, newText: string | null | undefined) { this.range = range; - this.newText = newText; + this.newText = newText || ''; } toJSON(): any { diff --git a/src/vs/workbench/parts/markers/test/electron-browser/markersModel.test.ts b/src/vs/workbench/parts/markers/test/electron-browser/markersModel.test.ts index 0b6b6ce606fd1..34eb1dfe3fcb3 100644 --- a/src/vs/workbench/parts/markers/test/electron-browser/markersModel.test.ts +++ b/src/vs/workbench/parts/markers/test/electron-browser/markersModel.test.ts @@ -117,11 +117,11 @@ suite('MarkersModel Test', () => { assert.equal(JSON.stringify({ ...marker, resource: marker.resource.path }, null, '\t'), new Marker(marker).toString()); marker = aMarker('a/res2', MarkerSeverity.Warning, 1, 2, 1, 8, 'Warning message', '', [{ startLineNumber: 2, startColumn: 5, endLineNumber: 2, endColumn: 10, message: 'some info', resource: URI.file('a/res3') }]); - const testObject = new Marker(marker, null); + const testObject = new Marker(marker, null!); // hack - (testObject as any).relatedInformation = marker.relatedInformation.map(r => new RelatedInformation(marker.resource, marker, r)); - assert.equal(JSON.stringify({ ...marker, resource: marker.resource.path, relatedInformation: marker.relatedInformation.map(r => ({ ...r, resource: r.resource.path })) }, null, '\t'), testObject.toString()); + (testObject as any).relatedInformation = marker.relatedInformation!.map(r => new RelatedInformation(marker.resource, marker, r)); + assert.equal(JSON.stringify({ ...marker, resource: marker.resource.path, relatedInformation: marker.relatedInformation!.map(r => ({ ...r, resource: r.resource.path })) }, null, '\t'), testObject.toString()); }); function compareResource(a: ResourceMarkers, b: string): boolean { diff --git a/src/vs/workbench/parts/snippets/test/electron-browser/snippetFile.test.ts b/src/vs/workbench/parts/snippets/test/electron-browser/snippetFile.test.ts index ea82ee5354378..bc798bf3433ba 100644 --- a/src/vs/workbench/parts/snippets/test/electron-browser/snippetFile.test.ts +++ b/src/vs/workbench/parts/snippets/test/electron-browser/snippetFile.test.ts @@ -11,7 +11,7 @@ suite('Snippets', function () { class TestSnippetFile extends SnippetFile { constructor(filepath: URI, snippets: Snippet[]) { - super(SnippetSource.Extension, filepath, undefined, undefined, undefined); + super(SnippetSource.Extension, filepath, undefined, undefined, undefined!); this.data.push(...snippets); } } diff --git a/src/vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts b/src/vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts index 9af0d874464d8..873bd9fd0200a 100644 --- a/src/vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts +++ b/src/vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts @@ -67,7 +67,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); const model = TextModel.createFromString('', undefined, modeService.getLanguageIdentifier('fooLang')); - return provider.provideCompletionItems(model, new Position(1, 1)).then(result => { + return provider.provideCompletionItems(model, new Position(1, 1))!.then(result => { assert.equal(result.incomplete, undefined); assert.equal(result.suggestions.length, 2); }); @@ -78,7 +78,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); const model = TextModel.createFromString('bar', undefined, modeService.getLanguageIdentifier('fooLang')); - return provider.provideCompletionItems(model, new Position(1, 4)).then(result => { + return provider.provideCompletionItems(model, new Position(1, 4))!.then(result => { assert.equal(result.incomplete, undefined); assert.equal(result.suggestions.length, 1); assert.equal(result.suggestions[0].label, 'bar'); @@ -110,7 +110,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); const model = TextModel.createFromString('bar-bar', undefined, modeService.getLanguageIdentifier('fooLang')); - await provider.provideCompletionItems(model, new Position(1, 3)).then(result => { + await provider.provideCompletionItems(model, new Position(1, 3))!.then(result => { assert.equal(result.incomplete, undefined); assert.equal(result.suggestions.length, 2); assert.equal(result.suggestions[0].label, 'bar'); @@ -121,7 +121,7 @@ suite('SnippetsService', function () { assert.equal(result.suggestions[1].range.startColumn, 1); }); - await provider.provideCompletionItems(model, new Position(1, 5)).then(result => { + await provider.provideCompletionItems(model, new Position(1, 5))!.then(result => { assert.equal(result.incomplete, undefined); assert.equal(result.suggestions.length, 1); assert.equal(result.suggestions[0].label, 'bar-bar'); @@ -129,7 +129,7 @@ suite('SnippetsService', function () { assert.equal(result.suggestions[0].range.startColumn, 1); }); - await provider.provideCompletionItems(model, new Position(1, 6)).then(result => { + await provider.provideCompletionItems(model, new Position(1, 6))!.then(result => { assert.equal(result.incomplete, undefined); assert.equal(result.suggestions.length, 2); assert.equal(result.suggestions[0].label, 'bar'); @@ -155,19 +155,19 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('\t { + return provider.provideCompletionItems(model, new Position(1, 7))!.then(result => { assert.equal(result.suggestions.length, 1); model.dispose(); model = TextModel.createFromString('\t { assert.equal(result.suggestions.length, 1); assert.equal(result.suggestions[0].range.startColumn, 2); model.dispose(); model = TextModel.createFromString('a { assert.equal(result.suggestions.length, 1); assert.equal(result.suggestions[0].range.startColumn, 2); @@ -190,9 +190,9 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('\n\t\n>/head>', undefined, modeService.getLanguageIdentifier('fooLang')); - return provider.provideCompletionItems(model, new Position(1, 1)).then(result => { + return provider.provideCompletionItems(model, new Position(1, 1))!.then(result => { assert.equal(result.suggestions.length, 1); - return provider.provideCompletionItems(model, new Position(2, 2)); + return provider.provideCompletionItems(model, new Position(2, 2))!; }).then(result => { assert.equal(result.suggestions.length, 1); }); @@ -220,7 +220,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('', undefined, modeService.getLanguageIdentifier('fooLang')); - return provider.provideCompletionItems(model, new Position(1, 1)).then(result => { + return provider.provideCompletionItems(model, new Position(1, 1))!.then(result => { assert.equal(result.suggestions.length, 2); let [first, second] = result.suggestions; assert.equal(first.label, 'first'); @@ -242,13 +242,13 @@ suite('SnippetsService', function () { let model = TextModel.createFromString('p-', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 2)); + let result = await provider.provideCompletionItems(model, new Position(1, 2))!; assert.equal(result.suggestions.length, 1); - result = await provider.provideCompletionItems(model, new Position(1, 3)); + result = await provider.provideCompletionItems(model, new Position(1, 3))!; assert.equal(result.suggestions.length, 1); - result = await provider.provideCompletionItems(model, new Position(1, 3)); + result = await provider.provideCompletionItems(model, new Position(1, 3))!; assert.equal(result.suggestions.length, 1); }); @@ -266,7 +266,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('Thisisaverylonglinegoingwithmore100bcharactersandthismakesintellisensebecomea Thisisaverylonglinegoingwithmore100bcharactersandthismakesintellisensebecomea b', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 158)); + let result = await provider.provideCompletionItems(model, new Position(1, 158))!; assert.equal(result.suggestions.length, 1); }); @@ -285,7 +285,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString(':', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 2)); + let result = await provider.provideCompletionItems(model, new Position(1, 2))!; assert.equal(result.suggestions.length, 0); }); @@ -304,7 +304,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('template', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 9)); + let result = await provider.provideCompletionItems(model, new Position(1, 9))!; assert.equal(result.suggestions.length, 1); assert.equal(result.suggestions[0].label, 'mytemplate'); @@ -324,13 +324,13 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('Thisisaverylonglinegoingwithmore100bcharactersandthismakesintellisensebecomea Thisisaverylonglinegoingwithmore100bcharactersandthismakesintellisensebecomea b text_after_b', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 158)); + let result = await provider.provideCompletionItems(model, new Position(1, 158))!; assert.equal(result.suggestions.length, 1); }); test('issue #61296: VS code freezes when editing CSS file with emoji', async function () { - let toDispose = LanguageConfigurationRegistry.register(modeService.getLanguageIdentifier('fooLang'), { + let toDispose = LanguageConfigurationRegistry.register(modeService.getLanguageIdentifier('fooLang')!, { wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g }); snippetService = new SimpleSnippetService([new Snippet( @@ -346,7 +346,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('.🐷-a-b', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 8)); + let result = await provider.provideCompletionItems(model, new Position(1, 8))!; assert.equal(result.suggestions.length, 1); @@ -367,7 +367,7 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString('a ', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 3)); + let result = await provider.provideCompletionItems(model, new Position(1, 3))!; assert.equal(result.suggestions.length, 1); }); @@ -394,14 +394,14 @@ suite('SnippetsService', function () { const provider = new SnippetCompletionProvider(modeService, snippetService); let model = TextModel.createFromString(' <', undefined, modeService.getLanguageIdentifier('fooLang')); - let result = await provider.provideCompletionItems(model, new Position(1, 3)); + let result = await provider.provideCompletionItems(model, new Position(1, 3))!; assert.equal(result.suggestions.length, 1); let [first] = result.suggestions; assert.equal(first.range.startColumn, 2); model = TextModel.createFromString('1', undefined, modeService.getLanguageIdentifier('fooLang')); - result = await provider.provideCompletionItems(model, new Position(1, 2)); + result = await provider.provideCompletionItems(model, new Position(1, 2))!; assert.equal(result.suggestions.length, 1); [first] = result.suggestions; diff --git a/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts b/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts index c5729bc158e34..e4e226e364565 100644 --- a/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts +++ b/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts @@ -16,7 +16,7 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati * This module contains utility functions related to the environment, cwd and paths. */ -export function mergeEnvironments(parent: platform.IProcessEnvironment, other: ITerminalEnvironment): void { +export function mergeEnvironments(parent: platform.IProcessEnvironment, other?: ITerminalEnvironment): void { if (!other) { return; } @@ -127,7 +127,7 @@ function _getLangEnvVariable(locale?: string) { return parts.join('_') + '.UTF-8'; } -export function getCwd(shell: IShellLaunchConfig, root: Uri, customCwd: string): string { +export function getCwd(shell: IShellLaunchConfig, root?: Uri, customCwd?: string): string { if (shell.cwd) { return (typeof shell.cwd === 'object') ? shell.cwd.path : shell.cwd; } diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts index 0715b95f21f65..ae957e55949bf 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts @@ -21,14 +21,14 @@ suite('Workbench - TerminalConfigHelper', () => { configurationService.setUserConfiguration('editor', { fontFamily: 'foo' }); configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: 'bar' } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontFamily, 'bar', 'terminal.integrated.fontFamily should be selected over editor.fontFamily'); configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: null } }); // Recreate config helper as onDidChangeConfiguration isn't implemented in TestConfigurationService - configHelper = new TerminalConfigHelper(configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; if (isFedora) { assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\', monospace', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set'); @@ -52,7 +52,7 @@ suite('Workbench - TerminalConfigHelper', () => { fontSize: 10 } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize'); @@ -65,7 +65,7 @@ suite('Workbench - TerminalConfigHelper', () => { fontSize: 0 } }); - configHelper = new TerminalConfigHelper(configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; if (isUbuntu) { assert.equal(configHelper.getFont().fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it'); @@ -81,7 +81,7 @@ suite('Workbench - TerminalConfigHelper', () => { fontSize: 1500 } }); - configHelper = new TerminalConfigHelper(configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontSize, 25, 'The maximum terminal font size should be used when terminal.integrated.fontSize more than it'); @@ -94,7 +94,7 @@ suite('Workbench - TerminalConfigHelper', () => { fontSize: null } }); - configHelper = new TerminalConfigHelper(configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; if (isUbuntu) { assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set'); @@ -116,7 +116,7 @@ suite('Workbench - TerminalConfigHelper', () => { lineHeight: 2 } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight'); @@ -130,7 +130,7 @@ suite('Workbench - TerminalConfigHelper', () => { lineHeight: 0 } }); - configHelper = new TerminalConfigHelper(configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().lineHeight, 1, 'editor.lineHeight should be 1 when terminal.integrated.lineHeight not set'); }); @@ -143,7 +143,7 @@ suite('Workbench - TerminalConfigHelper', () => { } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.configFontIsMonospace(), true, 'monospace is monospaced'); }); @@ -155,7 +155,7 @@ suite('Workbench - TerminalConfigHelper', () => { fontFamily: 'sans-serif' } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.configFontIsMonospace(), false, 'sans-serif is not monospaced'); }); @@ -167,7 +167,7 @@ suite('Workbench - TerminalConfigHelper', () => { fontFamily: 'serif' } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.configFontIsMonospace(), false, 'serif is not monospaced'); }); @@ -183,7 +183,7 @@ suite('Workbench - TerminalConfigHelper', () => { } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.configFontIsMonospace(), true, 'monospace is monospaced'); }); @@ -199,7 +199,7 @@ suite('Workbench - TerminalConfigHelper', () => { } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.configFontIsMonospace(), false, 'sans-serif is not monospaced'); }); @@ -215,7 +215,7 @@ suite('Workbench - TerminalConfigHelper', () => { } }); - let configHelper = new TerminalConfigHelper(configurationService, null, null, null); + let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!); configHelper.panelContainer = fixture; assert.equal(configHelper.configFontIsMonospace(), false, 'serif is not monospaced'); }); diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts index 772881d560806..1cc1487e224dd 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts @@ -14,7 +14,7 @@ class TestTerminalLinkHandler extends TerminalLinkHandler { public get localLinkRegex(): RegExp { return this._localLinkRegex; } - public preprocessPath(link: string): string { + public preprocessPath(link: string): string | null { return this._preprocessPath(link); } } @@ -33,7 +33,7 @@ interface LinkFormatInfo { suite('Workbench - TerminalLinkHandler', () => { suite('localLinkRegex', () => { test('Windows', () => { - const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null, null, null, null); + const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!); function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); @@ -105,7 +105,7 @@ suite('Workbench - TerminalLinkHandler', () => { }); test('Linux', () => { - const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null); + const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!); function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); @@ -169,7 +169,7 @@ suite('Workbench - TerminalLinkHandler', () => { suite('preprocessPath', () => { test('Windows', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!); linkHandler.processCwd = 'C:\\base'; let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) { @@ -182,7 +182,7 @@ suite('Workbench - TerminalLinkHandler', () => { stub.restore(); }); test('Windows - spaces', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null!, null!, null!, null!); linkHandler.processCwd = 'C:\\base dir'; let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) { @@ -196,7 +196,7 @@ suite('Workbench - TerminalLinkHandler', () => { }); test('Linux', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!); linkHandler.processCwd = '/base'; let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) { @@ -210,7 +210,7 @@ suite('Workbench - TerminalLinkHandler', () => { }); test('No Workspace', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null!, null!, null!, null!); assert.equal(linkHandler.preprocessPath('./src/file1'), null); assert.equal(linkHandler.preprocessPath('src/file2'), null); diff --git a/src/vs/workbench/parts/terminal/test/node/terminalEnvironment.test.ts b/src/vs/workbench/parts/terminal/test/node/terminalEnvironment.test.ts index ddea8da94e17a..9cacf39cad4be 100644 --- a/src/vs/workbench/parts/terminal/test/node/terminalEnvironment.test.ts +++ b/src/vs/workbench/parts/terminal/test/node/terminalEnvironment.test.ts @@ -91,7 +91,7 @@ suite('Workbench - TerminalEnvironment', () => { a: 'b', c: 'd' }; - const other: IStringDictionary = { + const other: IStringDictionary = { a: null }; terminalEnvironment.mergeEnvironments(parent, other); @@ -108,7 +108,7 @@ suite('Workbench - TerminalEnvironment', () => { a: 'b', c: 'd' }; - const other: IStringDictionary = { + const other: IStringDictionary = { A: null }; terminalEnvironment.mergeEnvironments(parent, other); @@ -125,31 +125,31 @@ suite('Workbench - TerminalEnvironment', () => { } test('should default to os.homedir() for an empty workspace', () => { - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, null, undefined), os.homedir()); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, undefined, undefined), os.homedir()); }); test('should use to the workspace if it exists', () => { - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, Uri.file('/foo'), undefined), '/foo'); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, Uri.file('/foo'), undefined), '/foo'); }); test('should use an absolute custom cwd as is', () => { - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, null, '/foo'), '/foo'); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, undefined, '/foo'), '/foo'); }); test('should normalize a relative custom cwd against the workspace path', () => { - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, Uri.file('/bar'), 'foo'), '/bar/foo'); - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, Uri.file('/bar'), './foo'), '/bar/foo'); - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, Uri.file('/bar'), '../foo'), '/foo'); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, Uri.file('/bar'), 'foo'), '/bar/foo'); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, Uri.file('/bar'), './foo'), '/bar/foo'); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, Uri.file('/bar'), '../foo'), '/foo'); }); test('should fall back for relative a custom cwd that doesn\'t have a workspace', () => { - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, null, 'foo'), os.homedir()); - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, null, './foo'), os.homedir()); - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [] }, null, '../foo'), os.homedir()); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, undefined, 'foo'), os.homedir()); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, undefined, './foo'), os.homedir()); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [] }, undefined, '../foo'), os.homedir()); }); test('should ignore custom cwd when told to ignore', () => { - assertPathsMatch(terminalEnvironment.getCwd({ executable: null, args: [], ignoreConfigurationCwd: true }, Uri.file('/bar'), '/foo'), '/bar'); + assertPathsMatch(terminalEnvironment.getCwd({ executable: undefined, args: [], ignoreConfigurationCwd: true }, Uri.file('/bar'), '/foo'), '/bar'); }); }); diff --git a/src/vs/workbench/services/commands/test/common/commandService.test.ts b/src/vs/workbench/services/commands/test/common/commandService.test.ts index a6f755291a400..62bf60ac6b9f8 100644 --- a/src/vs/workbench/services/commands/test/common/commandService.test.ts +++ b/src/vs/workbench/services/commands/test/common/commandService.test.ts @@ -18,9 +18,9 @@ class SimpleExtensionService implements IExtensionService { get onDidRegisterExtensions(): Event { return this._onDidRegisterExtensions.event; } - onDidChangeExtensionsStatus = null; - onWillActivateByEvent = null; - onDidChangeResponsiveChange = null; + onDidChangeExtensionsStatus = null!; + onWillActivateByEvent = null!; + onDidChangeResponsiveChange = null!; activateByEvent(activationEvent: string): Promise { return this.whenInstalledExtensionsRegistered().then(() => { }); } @@ -31,7 +31,7 @@ class SimpleExtensionService implements IExtensionService { return Promise.resolve([]); } getExtensionsStatus() { - return undefined; + return undefined!; } getExtensions(): Promise { return Promise.resolve([]); @@ -138,7 +138,7 @@ suite('CommandService', function () { assert.equal(callCounter, 0); let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1); - resolveFunc(true); + resolveFunc!(true); return r.then(() => { reg.dispose(); diff --git a/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts b/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts index cb96ed7bbb36a..2abf49537b364 100644 --- a/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts +++ b/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts @@ -201,7 +201,7 @@ suite('AllKeysConfigurationChangeEvent', () => { test('changeEvent affects keys for any resource', () => { const configuraiton = new Configuration(new ConfigurationModel({}, ['window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows']), - new ConfigurationModel(), new ConfigurationModel(), new ResourceMap(), new ConfigurationModel(), new ResourceMap(), null); + new ConfigurationModel(), new ConfigurationModel(), new ResourceMap(), new ConfigurationModel(), new ResourceMap(), null!); let testObject = new AllKeysConfigurationChangeEvent(configuraiton, ConfigurationTarget.USER, null); assert.deepEqual(testObject.affectedKeys, ['window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows']); diff --git a/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts b/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts index 45e6887137f10..19be00601612c 100644 --- a/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts +++ b/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts @@ -50,7 +50,7 @@ suite('DecorationsService', function () { assert.equal(e.affectsResource(uri), true); // sync result - assert.deepEqual(service.getDecoration(uri, false).tooltip, 'T'); + assert.deepEqual(service.getDecoration(uri, false)!.tooltip, 'T'); assert.equal(callCounter, 1); }); }); @@ -70,7 +70,7 @@ suite('DecorationsService', function () { }); // trigger -> sync - assert.deepEqual(service.getDecoration(uri, false).tooltip, 'Z'); + assert.deepEqual(service.getDecoration(uri, false)!.tooltip, 'Z'); assert.equal(callCounter, 1); }); @@ -88,7 +88,7 @@ suite('DecorationsService', function () { }); // trigger -> sync - assert.deepEqual(service.getDecoration(uri, false).tooltip, 'J'); + assert.deepEqual(service.getDecoration(uri, false)!.tooltip, 'J'); assert.equal(callCounter, 1); // un-register -> ensure good event @@ -121,10 +121,10 @@ suite('DecorationsService', function () { let childUri = URI.parse('file:///some/path/some/file.txt'); - let deco = service.getDecoration(childUri, false); + let deco = service.getDecoration(childUri, false)!; assert.equal(deco.tooltip, '.txt'); - deco = service.getDecoration(childUri.with({ path: 'some/path/' }), true); + deco = service.getDecoration(childUri.with({ path: 'some/path/' }), true)!; assert.equal(deco, undefined); reg.dispose(); @@ -139,10 +139,10 @@ suite('DecorationsService', function () { } }); - deco = service.getDecoration(childUri, false); + deco = service.getDecoration(childUri, false)!; assert.equal(deco.tooltip, '.txt.bubble'); - deco = service.getDecoration(childUri.with({ path: 'some/path/' }), true); + deco = service.getDecoration(childUri.with({ path: 'some/path/' }), true)!; assert.equal(typeof deco.tooltip, 'string'); }); @@ -152,7 +152,7 @@ suite('DecorationsService', function () { let deco = service.getDecoration(someUri, false); assert.equal(deco, undefined); - deco = service.getDecoration(someUri, false, { tooltip: 'Overwrite' }); + deco = service.getDecoration(someUri, false, { tooltip: 'Overwrite' })!; assert.equal(deco.tooltip, 'Overwrite'); let reg = service.registerDecorationsProvider({ @@ -163,10 +163,10 @@ suite('DecorationsService', function () { } }); - deco = service.getDecoration(someUri, false); + deco = service.getDecoration(someUri, false)!; assert.equal(deco.tooltip, 'FromMe'); - deco = service.getDecoration(someUri, false, { source: 'foo', tooltip: 'O' }); + deco = service.getDecoration(someUri, false, { source: 'foo', tooltip: 'O' })!; assert.equal(deco.tooltip, 'O'); reg.dispose(); @@ -232,7 +232,7 @@ suite('DecorationsService', function () { let data1 = service.getDecoration(URI.parse('a:b/'), true); assert.ok(!data1); - let data2 = service.getDecoration(URI.parse('a:b/c.hello'), false); + let data2 = service.getDecoration(URI.parse('a:b/c.hello'), false)!; assert.ok(data2.tooltip); let data3 = service.getDecoration(URI.parse('a:b/'), true); @@ -259,19 +259,19 @@ suite('DecorationsService', function () { let uri = URI.parse('foo:/folder/file.ts'); let uri2 = URI.parse('foo:/folder/'); - let data = service.getDecoration(uri, true); + let data = service.getDecoration(uri, true)!; assert.equal(data.tooltip, 'FOO'); - data = service.getDecoration(uri2, true); + data = service.getDecoration(uri2, true)!; assert.ok(data.tooltip); // emphazied items... gone = true; emitter.fire([uri]); - data = service.getDecoration(uri, true); + data = service.getDecoration(uri, true)!; assert.equal(data, undefined); - data = service.getDecoration(uri2, true); + data = service.getDecoration(uri2, true)!; assert.equal(data, undefined); reg.dispose(); @@ -294,10 +294,10 @@ suite('DecorationsService', function () { let uri = URI.parse('foo:/folder/file.ts'); let uri2 = URI.parse('foo:/folder/'); - let data = service.getDecoration(uri, true); + let data = service.getDecoration(uri, true)!; assert.equal(data.tooltip, 'FOO'); - data = service.getDecoration(uri2, true); + data = service.getDecoration(uri2, true)!; assert.ok(data.tooltip); // emphazied items... return new Promise((resolve, reject) => { diff --git a/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts b/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts index 73716a4861928..1bd9341239fe7 100644 --- a/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts +++ b/src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts @@ -46,8 +46,6 @@ suite('RPCProtocol', () => { let A = new RPCProtocol(a_protocol); let B = new RPCProtocol(b_protocol); - delegate = null; - const bIdentifier = new ProxyIdentifier(false, 'bb'); const bInstance = new BClass(); B.set(bIdentifier, bInstance); 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..e73689a691b42 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/keybinding/test/keybindingIO.test.ts b/src/vs/workbench/services/keybinding/test/keybindingIO.test.ts index 4f3366267c949..4a3ae32202834 100644 --- a/src/vs/workbench/services/keybinding/test/keybindingIO.test.ts +++ b/src/vs/workbench/services/keybinding/test/keybindingIO.test.ts @@ -16,7 +16,7 @@ suite('keybindingIO', () => { test('serialize/deserialize', () => { function testOneSerialization(keybinding: number, expected: string, msg: string, OS: OperatingSystem): void { - let usLayoutResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS), OS); + let usLayoutResolvedKeybinding = new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS); let actualSerialized = usLayoutResolvedKeybinding.getUserSettingsLabel(); assert.equal(actualSerialized, expected, expected + ' - ' + msg); } diff --git a/src/vs/workbench/services/keybinding/test/keyboardMapperTestUtils.ts b/src/vs/workbench/services/keybinding/test/keyboardMapperTestUtils.ts index a49ecccfd2336..28193723b8139 100644 --- a/src/vs/workbench/services/keybinding/test/keyboardMapperTestUtils.ts +++ b/src/vs/workbench/services/keybinding/test/keyboardMapperTestUtils.ts @@ -44,7 +44,7 @@ export function assertResolveKeyboardEvent(mapper: IKeyboardMapper, keyboardEven assert.deepEqual(actual, expected); } -export function assertResolveUserBinding(mapper: IKeyboardMapper, firstPart: SimpleKeybinding | ScanCodeBinding, chordPart: SimpleKeybinding | ScanCodeBinding, expected: IResolvedKeybinding[]): void { +export function assertResolveUserBinding(mapper: IKeyboardMapper, firstPart: SimpleKeybinding | ScanCodeBinding, chordPart: SimpleKeybinding | ScanCodeBinding | null, expected: IResolvedKeybinding[]): void { let actual: IResolvedKeybinding[] = mapper.resolveUserBinding(firstPart, chordPart).map(toIResolvedKeybinding); assert.deepEqual(actual, expected); } diff --git a/src/vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts b/src/vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts index 36ad8ef22fa6f..72905db8fe580 100644 --- a/src/vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts +++ b/src/vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts @@ -14,7 +14,7 @@ suite('keyboardMapper - MAC fallback', () => { let mapper = new MacLinuxFallbackKeyboardMapper(OperatingSystem.Macintosh); function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Macintosh)!, expected); } test('resolveKeybinding Cmd+Z', () => { @@ -56,7 +56,7 @@ suite('keyboardMapper - MAC fallback', () => { altKey: false, metaKey: true, keyCode: KeyCode.KEY_Z, - code: null + code: null! }, { label: '⌘Z', @@ -96,7 +96,7 @@ suite('keyboardMapper - MAC fallback', () => { altKey: false, metaKey: true, keyCode: KeyCode.Meta, - code: null + code: null! }, { label: '⌘', @@ -116,7 +116,7 @@ suite('keyboardMapper - LINUX fallback', () => { let mapper = new MacLinuxFallbackKeyboardMapper(OperatingSystem.Linux); function _assertResolveKeybinding(k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Linux)!, expected); } test('resolveKeybinding Ctrl+Z', () => { @@ -158,7 +158,7 @@ suite('keyboardMapper - LINUX fallback', () => { altKey: false, metaKey: false, keyCode: KeyCode.KEY_Z, - code: null + code: null! }, { label: 'Ctrl+Z', @@ -215,7 +215,7 @@ suite('keyboardMapper - LINUX fallback', () => { altKey: false, metaKey: false, keyCode: KeyCode.Ctrl, - code: null + code: null! }, { label: 'Ctrl+', diff --git a/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts b/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts index 0e0c5c7beada3..18cf13242e91b 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', () => { @@ -1127,7 +1127,7 @@ suite('keyboardMapper - LINUX en_us', () => { assertResolveUserBinding( mapper, new ScanCodeBinding(true, false, false, false, ScanCode.Comma), - null, + null!, [{ label: 'Ctrl+,', ariaLabel: 'Control+,', @@ -1224,7 +1224,7 @@ suite('keyboardMapper', () => { test('issue #24064: NumLock/NumPad keys stopped working in 1.11 on Linux', () => { let mapper = new MacLinuxKeyboardMapper(false, {}, OperatingSystem.Linux); - function assertNumpadKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string, userSettingsLabel: string, dispatch: string): void { + function assertNumpadKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string | null, userSettingsLabel: string, dispatch: string): void { assertResolveKeyboardEvent( mapper, { @@ -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/keybinding/test/windowsKeyboardMapper.test.ts b/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts index 5fafd8cf16663..42dc8a2a38309 100644 --- a/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts +++ b/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts @@ -17,7 +17,7 @@ async function createKeyboardMapper(isUSStandard: boolean, file: string): Promis } function _assertResolveKeybinding(mapper: WindowsKeyboardMapper, k: number, expected: IResolvedKeybinding[]): void { - assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Windows), expected); + assertResolveKeybinding(mapper, createKeybinding(k, OperatingSystem.Windows)!, expected); } suite('keyboardMapper - WINDOWS de_ch', () => { @@ -73,7 +73,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => { altKey: false, metaKey: false, keyCode: KeyCode.KEY_Z, - code: null + code: null! }, { label: 'Ctrl+Z', @@ -112,7 +112,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => { altKey: false, metaKey: false, keyCode: KeyCode.US_CLOSE_SQUARE_BRACKET, - code: null + code: null! }, { label: 'Ctrl+^', @@ -255,7 +255,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => { altKey: false, metaKey: false, keyCode: KeyCode.Home, - code: null + code: null! }, { label: 'Ctrl+Home', @@ -295,7 +295,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => { altKey: false, metaKey: false, keyCode: KeyCode.Ctrl, - code: null + code: null! }, { label: 'Ctrl+', @@ -359,7 +359,7 @@ suite('keyboardMapper - WINDOWS en_us', () => { assertResolveUserBinding( mapper, new ScanCodeBinding(true, false, false, false, ScanCode.Comma), - null, + null!, [{ label: 'Ctrl+,', ariaLabel: 'Control+,', @@ -381,7 +381,7 @@ suite('keyboardMapper - WINDOWS en_us', () => { altKey: false, metaKey: false, keyCode: KeyCode.Ctrl, - code: null + code: null! }, { label: 'Ctrl+', @@ -417,7 +417,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => { altKey: false, metaKey: false, keyCode: KeyCode.ABNT_C1, - code: null + code: null! }, { label: 'Ctrl+/', @@ -440,7 +440,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => { altKey: false, metaKey: false, keyCode: KeyCode.ABNT_C2, - code: null + code: null! }, { label: 'Ctrl+.', diff --git a/src/vs/workbench/test/common/notifications.test.ts b/src/vs/workbench/test/common/notifications.test.ts index 282f6d63df567..69b3d465ea37a 100644 --- a/src/vs/workbench/test/common/notifications.test.ts +++ b/src/vs/workbench/test/common/notifications.test.ts @@ -15,14 +15,14 @@ suite('Notifications', () => { // Invalid assert.ok(!NotificationViewItem.create({ severity: Severity.Error, message: '' })); - assert.ok(!NotificationViewItem.create({ severity: Severity.Error, message: null })); + assert.ok(!NotificationViewItem.create({ severity: Severity.Error, message: null! })); // Duplicates - let item1 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' }); - let item2 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' }); - let item3 = NotificationViewItem.create({ severity: Severity.Info, message: 'Info Message' }); - let item4 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message', source: 'Source' }); - let item5 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message', actions: { primary: [new Action('id', 'label')] } }); + let item1 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' })!; + let item2 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' })!; + let item3 = NotificationViewItem.create({ severity: Severity.Info, message: 'Info Message' })!; + let item4 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message', source: 'Source' })!; + let item5 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message', actions: { primary: [new Action('id', 'label')] } })!; assert.equal(item1.equals(item1), true); assert.equal(item2.equals(item2), true); @@ -102,11 +102,11 @@ suite('Notifications', () => { assert.equal(called, 1); // Error with Action - let item6 = NotificationViewItem.create({ severity: Severity.Error, message: createErrorWithActions('Hello Error', { actions: [new Action('id', 'label')] }) }); - assert.equal(item6.actions.primary.length, 1); + let item6 = NotificationViewItem.create({ severity: Severity.Error, message: createErrorWithActions('Hello Error', { actions: [new Action('id', 'label')] }) })!; + assert.equal(item6.actions.primary!.length, 1); // Links - let item7 = NotificationViewItem.create({ severity: Severity.Info, message: 'Unable to [Link 1](http://link1.com) open [Link 2](https://link2.com) and [Invalid Link3](ftp://link3.com)' }); + let item7 = NotificationViewItem.create({ severity: Severity.Info, message: 'Unable to [Link 1](http://link1.com) open [Link 2](https://link2.com) and [Invalid Link3](ftp://link3.com)' })!; const links = item7.message.links; assert.equal(links.length, 2); @@ -124,7 +124,7 @@ suite('Notifications', () => { test('Model', () => { const model = new NotificationsModel(); - let lastEvent: INotificationChangeEvent; + let lastEvent!: INotificationChangeEvent; model.onDidNotificationChange(e => { lastEvent = e; }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts index 6e121e81c9228..c2239b9b7a083 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts @@ -56,7 +56,7 @@ suite('ExtHostTypes', function () { d.dispose(); assert.equal(count, 1); - types.Disposable.from(undefined, { dispose() { count += 1; } }).dispose(); + types.Disposable.from(undefined!, { dispose() { count += 1; } }).dispose(); assert.equal(count, 2); @@ -66,7 +66,7 @@ suite('ExtHostTypes', function () { }).dispose(); }); - new types.Disposable(undefined).dispose(); + new types.Disposable(undefined!).dispose(); }); @@ -154,11 +154,11 @@ suite('ExtHostTypes', function () { assert.equal(res.line, 12); assert.equal(res.character, 3); - assert.throws(() => p1.translate(null)); - assert.throws(() => p1.translate(null, null)); + assert.throws(() => p1.translate(null!)); + assert.throws(() => p1.translate(null!, null!)); assert.throws(() => p1.translate(-2)); assert.throws(() => p1.translate({ lineDelta: -2 })); - assert.throws(() => p1.translate(-2, null)); + assert.throws(() => p1.translate(-2, null!)); assert.throws(() => p1.translate(0, -4)); }); @@ -178,7 +178,7 @@ suite('ExtHostTypes', function () { assert.equal(p2.line, 0); assert.equal(p2.character, 11); - assert.throws(() => p1.with(null)); + assert.throws(() => p1.with(null!)); assert.throws(() => p1.with(-9)); assert.throws(() => p1.with(0, -9)); assert.throws(() => p1.with({ line: -1 })); @@ -188,10 +188,10 @@ suite('ExtHostTypes', function () { test('Range', () => { assert.throws(() => new types.Range(-1, 0, 0, 0)); assert.throws(() => new types.Range(0, -1, 0, 0)); - assert.throws(() => new types.Range(new types.Position(0, 0), undefined)); - assert.throws(() => new types.Range(new types.Position(0, 0), null)); - assert.throws(() => new types.Range(undefined, new types.Position(0, 0))); - assert.throws(() => new types.Range(null, new types.Position(0, 0))); + assert.throws(() => new types.Range(new types.Position(0, 0), undefined!)); + assert.throws(() => new types.Range(new types.Position(0, 0), null!)); + assert.throws(() => new types.Range(undefined!, new types.Position(0, 0))); + assert.throws(() => new types.Range(null!, new types.Position(0, 0))); let range = new types.Range(1, 0, 0, 0); assert.throws(() => { (range as any).start = null; }); @@ -250,30 +250,30 @@ suite('ExtHostTypes', function () { let range = new types.Range(1, 1, 2, 11); let res: types.Range; - res = range.intersection(range); + res = range.intersection(range)!; assert.equal(res.start.line, 1); assert.equal(res.start.character, 1); assert.equal(res.end.line, 2); assert.equal(res.end.character, 11); - res = range.intersection(new types.Range(2, 12, 4, 0)); + res = range.intersection(new types.Range(2, 12, 4, 0))!; assert.equal(res, undefined); - res = range.intersection(new types.Range(0, 0, 1, 0)); + res = range.intersection(new types.Range(0, 0, 1, 0))!; assert.equal(res, undefined); - res = range.intersection(new types.Range(0, 0, 1, 1)); + res = range.intersection(new types.Range(0, 0, 1, 1))!; assert.ok(res.isEmpty); assert.equal(res.start.line, 1); assert.equal(res.start.character, 1); - res = range.intersection(new types.Range(2, 11, 61, 1)); + res = range.intersection(new types.Range(2, 11, 61, 1))!; assert.ok(res.isEmpty); assert.equal(res.start.line, 2); assert.equal(res.start.character, 11); - assert.throws(() => range.intersection(null)); - assert.throws(() => range.intersection(undefined)); + assert.throws(() => range.intersection(null!)); + assert.throws(() => range.intersection(undefined!)); }); test('Range, union', function () { @@ -325,8 +325,8 @@ suite('ExtHostTypes', function () { assert.equal(res.start.line, 2); assert.equal(res.start.character, 3); - assert.throws(() => range.with(null)); - assert.throws(() => range.with(undefined, null)); + assert.throws(() => range.with(null!)); + assert.throws(() => range.with(undefined, null!)); }); test('TextEdit', () => { @@ -365,7 +365,7 @@ suite('ExtHostTypes', function () { [b.toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]] ]); - edit.set(b, undefined); + edit.set(b, undefined!); assert.ok(!edit.has(b)); assert.equal(edit.size, 1); @@ -395,17 +395,17 @@ suite('ExtHostTypes', function () { } const [first, second, third, fourth] = all; - assert.equal(first[0].toString(), 'foo:a'); + assert.equal(first[0]!.toString(), 'foo:a'); assert.ok(!isFileChange(first)); assert.ok(isTextChange(first) && first[1].length === 1); - assert.equal(second[0].toString(), 'foo:a'); + assert.equal(second[0]!.toString(), 'foo:a'); assert.ok(isFileChange(second)); - assert.equal(third[0].toString(), 'foo:a'); + assert.equal(third[0]!.toString(), 'foo:a'); assert.ok(isTextChange(third) && third[1].length === 1); - assert.equal(fourth[0].toString(), 'foo:b'); + assert.equal(fourth[0]!.toString(), 'foo:b'); assert.ok(!isFileChange(fourth)); assert.ok(isTextChange(fourth) && fourth[1].length === 1); }); @@ -423,8 +423,8 @@ suite('ExtHostTypes', function () { }); test('DocumentLink', () => { - assert.throws(() => new types.DocumentLink(null, null)); - assert.throws(() => new types.DocumentLink(new types.Range(1, 1, 1, 1), null)); + assert.throws(() => new types.DocumentLink(null!, null!)); + assert.throws(() => new types.DocumentLink(new types.Range(1, 1, 1, 1), null!)); }); test('toJSON & stringify', function () { From 3c9bb8980b86f375af4d51a5c643f947108d5b22 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 21 Dec 2018 22:45:22 -0500 Subject: [PATCH 2/4] Fixed tsconfig.strictNullChecks.json merge fail --- src/tsconfig.strictNullChecks.json | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index fd16707e7cedb..5bf16f73f5a98 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -107,33 +107,26 @@ "./vs/base/test/browser/progressBar.test.ts", "./vs/base/test/browser/ui/contextview/contextview.test.ts", "./vs/base/test/browser/ui/grid/grid.test.ts", - "./vs/base/test/browser/ui/grid/gridview.test.ts", "./vs/base/test/browser/ui/grid/util.ts", "./vs/base/test/browser/ui/list/listView.test.ts", "./vs/base/test/browser/ui/list/rangeMap.test.ts", "./vs/base/test/browser/ui/scrollbar/scrollableElement.test.ts", "./vs/base/test/browser/ui/scrollbar/scrollbarState.test.ts", - "./vs/base/test/browser/ui/splitview/splitview.test.ts", "./vs/base/test/browser/ui/tree/asyncDataTree.test.ts", "./vs/base/test/browser/ui/tree/indexTreeModel.test.ts", "./vs/base/test/browser/ui/tree/objectTree.test.ts", "./vs/base/test/browser/ui/tree/objectTreeModel.test.ts", - "./vs/base/test/common/arrays.test.ts", "./vs/base/test/common/assert.test.ts", - "./vs/base/test/common/async.test.ts", "./vs/base/test/common/cache.test.ts", "./vs/base/test/common/cancellation.test.ts", "./vs/base/test/common/charCode.test.ts", "./vs/base/test/common/collections.test.ts", "./vs/base/test/common/color.test.ts", "./vs/base/test/common/decorators.test.ts", - "./vs/base/test/common/diff/diff.test.ts", "./vs/base/test/common/errors.test.ts", - "./vs/base/test/common/event.test.ts", "./vs/base/test/common/filters.perf.test.ts", "./vs/base/test/common/filters.test.ts", "./vs/base/test/common/hash.test.ts", - "./vs/base/test/common/history.test.ts", "./vs/base/test/common/json.test.ts", "./vs/base/test/common/jsonEdit.test.ts", "./vs/base/test/common/jsonFormatter.test.ts", @@ -835,7 +828,6 @@ "./vs/workbench/services/title/common/titleService.ts", "./vs/workbench/services/workspace/common/workspaceEditing.ts", "./vs/workbench/test/common/editor/editorOptions.test.ts", - "./vs/base/test/browser/comparers.test.ts", "./vs/base/test/browser/ui/grid/gridview.test.ts", "./vs/base/test/browser/ui/splitview/splitview.test.ts", "./vs/base/test/browser/ui/tree/asyncDataTree.test.ts", @@ -845,20 +837,7 @@ "./vs/base/test/common/event.test.ts", "./vs/base/test/common/history.test.ts", "./vs/base/test/common/keyCodes.test.ts", - "./vs/base/test/common/map.test.ts", - "./vs/base/test/common/octicon.test.ts", - "./vs/base/test/common/strings.test.ts", - "./vs/base/test/common/uri.test.ts", - "./vs/base/test/node/config.test.ts", - "./vs/base/test/node/extfs/extfs.test.ts", - "./vs/base/test/node/flow.test.ts", - "./vs/base/test/node/glob.test.ts", - "./vs/base/test/node/pfs.test.ts", "./vs/base/test/node/storage/storage.test.ts", - "./vs/code/test/node/windowsFinder.test.ts", - "./vs/editor/contrib/codeAction/test/codeAction.test.ts", - "./vs/editor/contrib/codeAction/test/codeActionModel.test.ts", - "./vs/editor/contrib/comment/test/lineCommentCommand.test.ts", "./vs/editor/contrib/find/test/findController.test.ts", "./vs/editor/contrib/linesOperations/test/linesOperations.test.ts", "./vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts", @@ -871,7 +850,6 @@ "./vs/platform/configuration/test/common/configurationModels.test.ts", "./vs/platform/contextkey/test/common/contextkey.test.ts", "./vs/platform/extensions/test/node/extensionValidator.test.ts", - "./vs/platform/files/test/files.test.ts", "./vs/platform/instantiation/test/common/instantiationService.test.ts", "./vs/platform/keybinding/test/common/abstractKeybindingService.test.ts", "./vs/platform/keybinding/test/common/keybindingLabels.test.ts", @@ -882,7 +860,6 @@ "./vs/workbench/parts/markers/test/electron-browser/markersModel.test.ts", "./vs/workbench/parts/snippets/test/electron-browser/snippetFile.test.ts", "./vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts", - "./vs/workbench/parts/stats/test/workspaceStats.test.ts", "./vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts", "./vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts", "./vs/workbench/parts/terminal/test/node/terminalEnvironment.test.ts", @@ -894,12 +871,9 @@ "./vs/workbench/services/keybinding/test/keybindingIO.test.ts", "./vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts", "./vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts", - "./vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts", - "./vs/workbench/test/common/notifications.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", ], "exclude": [ "./typings/require-monaco.d.ts" From 887853bf93c58f4673dd8982050631f0fc2e3147 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 21 Dec 2018 22:58:09 -0500 Subject: [PATCH 3/4] Touched up a few unnecessary type changes --- src/vs/base/parts/tree/test/browser/treeModel.test.ts | 2 +- src/vs/base/test/browser/comparers.test.ts | 10 +++++----- src/vs/workbench/api/node/extHostTypes.ts | 4 ++-- .../test/electron-browser/api/extHostTypes.test.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) 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 36b3853941cd5..baa5350b49da0 100644 --- a/src/vs/base/parts/tree/test/browser/treeModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeModel.test.ts @@ -72,7 +72,7 @@ class EventCounter { this._count = 0; } - public listen(event: Event, fn: (e: T) => void | null | null = null): () => void { + public listen(event: Event, fn: ((e: T) => void) | null = null): () => void { let r = event(data => { this._count++; if (fn) { diff --git a/src/vs/base/test/browser/comparers.test.ts b/src/vs/base/test/browser/comparers.test.ts index 7a12914d3e376..df74e2bbfa2d8 100644 --- a/src/vs/base/test/browser/comparers.test.ts +++ b/src/vs/base/test/browser/comparers.test.ts @@ -20,8 +20,8 @@ suite('Comparers', () => { }; })); - assert(compareFileNames(null!, null!) === 0, 'null should be equal'); - assert(compareFileNames(null!, 'abc') < 0, 'null should be come before real values'); + assert(compareFileNames(null, null) === 0, 'null should be equal'); + assert(compareFileNames(null, 'abc') < 0, 'null should be come before real values'); assert(compareFileNames('', '') === 0, 'empty should be equal'); assert(compareFileNames('abc', 'abc') === 0, 'equal names should be equal'); assert(compareFileNames('.abc', '.abc') === 0, 'equal full names should be equal'); @@ -44,9 +44,9 @@ suite('Comparers', () => { }; })); - assert(compareFileExtensions(null!, null!) === 0, 'null should be equal'); - assert(compareFileExtensions(null!, '.abc') < 0, 'null should come before real files'); - assert(compareFileExtensions(null!, 'abc') < 0, 'null should come before real files without extension'); + assert(compareFileExtensions(null, null) === 0, 'null should be equal'); + assert(compareFileExtensions(null, '.abc') < 0, 'null should come before real files'); + assert(compareFileExtensions(null, 'abc') < 0, 'null should come before real files without extension'); assert(compareFileExtensions('', '') === 0, 'empty should be equal'); assert(compareFileExtensions('abc', 'abc') === 0, 'equal names should be equal'); assert(compareFileExtensions('.abc', '.abc') === 0, 'equal full names should be equal'); diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index d0c9c6c170df2..ba390e1ff497e 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -453,7 +453,7 @@ export class TextEdit { } protected _range: Range; - protected _newText: string | null | undefined; + protected _newText: string; protected _newEol: EndOfLine; get range(): Range { @@ -489,7 +489,7 @@ export class TextEdit { this._newEol = value; } - constructor(range: Range, newText: string | null | undefined) { + constructor(range: Range, newText: string) { this.range = range; this.newText = newText || ''; } diff --git a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts index c2239b9b7a083..d2deeaf2163d5 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts @@ -332,11 +332,11 @@ suite('ExtHostTypes', function () { test('TextEdit', () => { let range = new types.Range(1, 1, 2, 11); - let edit = new types.TextEdit(range, undefined); + let edit = new types.TextEdit(range, undefined!); assert.equal(edit.newText, ''); assertToJSON(edit, { range: [{ line: 1, character: 1 }, { line: 2, character: 11 }], newText: '' }); - edit = new types.TextEdit(range, null); + edit = new types.TextEdit(range, null!); assert.equal(edit.newText, ''); edit = new types.TextEdit(range, ''); From 3bf15d797450d2689f44b4f6dc7821ffb4694707 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 22 Dec 2018 00:48:25 -0500 Subject: [PATCH 4/4] Removed files already in other PRs --- src/tsconfig.strictNullChecks.json | 23 ++---- src/vs/base/test/common/keyCodes.test.ts | 4 +- src/vs/base/test/node/storage/storage.test.ts | 4 +- .../contrib/find/test/findController.test.ts | 70 +++++++++---------- .../test/browser/simpleServices.test.ts | 4 +- .../platform/commands/test/commands.test.ts | 22 +++--- .../contextkey/test/common/contextkey.test.ts | 10 +-- .../common/abstractKeybindingService.test.ts | 40 +++++------ .../unix/test/chockidarWatcherService.test.ts | 4 +- .../test/macLinuxKeyboardMapper.test.ts | 16 ++--- 10 files changed, 94 insertions(+), 103 deletions(-) diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 5bf16f73f5a98..b87646cb5783d 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -107,26 +107,33 @@ "./vs/base/test/browser/progressBar.test.ts", "./vs/base/test/browser/ui/contextview/contextview.test.ts", "./vs/base/test/browser/ui/grid/grid.test.ts", + "./vs/base/test/browser/ui/grid/gridview.test.ts", "./vs/base/test/browser/ui/grid/util.ts", "./vs/base/test/browser/ui/list/listView.test.ts", "./vs/base/test/browser/ui/list/rangeMap.test.ts", "./vs/base/test/browser/ui/scrollbar/scrollableElement.test.ts", "./vs/base/test/browser/ui/scrollbar/scrollbarState.test.ts", + "./vs/base/test/browser/ui/splitview/splitview.test.ts", "./vs/base/test/browser/ui/tree/asyncDataTree.test.ts", "./vs/base/test/browser/ui/tree/indexTreeModel.test.ts", "./vs/base/test/browser/ui/tree/objectTree.test.ts", "./vs/base/test/browser/ui/tree/objectTreeModel.test.ts", + "./vs/base/test/common/arrays.test.ts", "./vs/base/test/common/assert.test.ts", + "./vs/base/test/common/async.test.ts", "./vs/base/test/common/cache.test.ts", "./vs/base/test/common/cancellation.test.ts", "./vs/base/test/common/charCode.test.ts", "./vs/base/test/common/collections.test.ts", "./vs/base/test/common/color.test.ts", "./vs/base/test/common/decorators.test.ts", + "./vs/base/test/common/diff/diff.test.ts", "./vs/base/test/common/errors.test.ts", + "./vs/base/test/common/event.test.ts", "./vs/base/test/common/filters.perf.test.ts", "./vs/base/test/common/filters.test.ts", "./vs/base/test/common/hash.test.ts", + "./vs/base/test/common/history.test.ts", "./vs/base/test/common/json.test.ts", "./vs/base/test/common/jsonEdit.test.ts", "./vs/base/test/common/jsonFormatter.test.ts", @@ -828,30 +835,16 @@ "./vs/workbench/services/title/common/titleService.ts", "./vs/workbench/services/workspace/common/workspaceEditing.ts", "./vs/workbench/test/common/editor/editorOptions.test.ts", - "./vs/base/test/browser/ui/grid/gridview.test.ts", - "./vs/base/test/browser/ui/splitview/splitview.test.ts", "./vs/base/test/browser/ui/tree/asyncDataTree.test.ts", - "./vs/base/test/common/arrays.test.ts", - "./vs/base/test/common/async.test.ts", - "./vs/base/test/common/diff/diff.test.ts", - "./vs/base/test/common/event.test.ts", - "./vs/base/test/common/history.test.ts", - "./vs/base/test/common/keyCodes.test.ts", - "./vs/base/test/node/storage/storage.test.ts", - "./vs/editor/contrib/find/test/findController.test.ts", "./vs/editor/contrib/linesOperations/test/linesOperations.test.ts", "./vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts", "./vs/editor/contrib/multicursor/test/multicursor.test.ts", "./vs/editor/contrib/suggest/test/completionModel.test.ts", "./vs/editor/contrib/wordOperations/test/wordOperations.test.ts", "./vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts", - "./vs/editor/standalone/test/browser/simpleServices.test.ts", - "./vs/platform/commands/test/commands.test.ts", "./vs/platform/configuration/test/common/configurationModels.test.ts", - "./vs/platform/contextkey/test/common/contextkey.test.ts", "./vs/platform/extensions/test/node/extensionValidator.test.ts", "./vs/platform/instantiation/test/common/instantiationService.test.ts", - "./vs/platform/keybinding/test/common/abstractKeybindingService.test.ts", "./vs/platform/keybinding/test/common/keybindingLabels.test.ts", "./vs/platform/keybinding/test/common/keybindingResolver.test.ts", "./vs/platform/markers/test/common/markerService.test.ts", @@ -867,10 +860,8 @@ "./vs/workbench/services/configuration/test/common/configurationModels.test.ts", "./vs/workbench/services/decorations/test/browser/decorationsService.test.ts", "./vs/workbench/services/extensions/test/node/rpcProtocol.test.ts", - "./vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts", "./vs/workbench/services/keybinding/test/keybindingIO.test.ts", "./vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.test.ts", - "./vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.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" diff --git a/src/vs/base/test/common/keyCodes.test.ts b/src/vs/base/test/common/keyCodes.test.ts index a45f859760901..bc746461f941b 100644 --- a/src/vs/base/test/common/keyCodes.test.ts +++ b/src/vs/base/test/common/keyCodes.test.ts @@ -19,7 +19,7 @@ suite('keyCodes', () => { testBinaryEncoding(expected, k, OperatingSystem.Macintosh); } - test(null!, 0); + test(null, 0); test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter), KeyCode.Enter); test(new SimpleKeybinding(true, false, false, false, KeyCode.Enter), KeyMod.WinCtrl | KeyCode.Enter); test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyCode.Enter); @@ -61,7 +61,7 @@ suite('keyCodes', () => { testBinaryEncoding(expected, k, OS); } - test(null!, 0); + test(null, 0); test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter), KeyCode.Enter); test(new SimpleKeybinding(false, false, false, true, KeyCode.Enter), KeyMod.WinCtrl | KeyCode.Enter); test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyCode.Enter); diff --git a/src/vs/base/test/node/storage/storage.test.ts b/src/vs/base/test/node/storage/storage.test.ts index 531c64d330371..134379de4abd2 100644 --- a/src/vs/base/test/node/storage/storage.test.ts +++ b/src/vs/base/test/node/storage/storage.test.ts @@ -138,7 +138,7 @@ suite('Storage Library', () => { change.set('foo', void 0); database.fireDidChangeItemsExternal({ items: change }); ok(changes.has('foo')); - equal(storage.get('foo', null!), null); + equal(storage.get('foo', null), null); changes.clear(); // Nothing happens if changing to same value @@ -272,7 +272,7 @@ suite('SQLite Storage Library', () => { }; } - const storage = new SQLiteStorageDatabase(path, options!); + const storage = new SQLiteStorageDatabase(path, options); const items = new Map(); items.set('foo', 'bar'); diff --git a/src/vs/editor/contrib/find/test/findController.test.ts b/src/vs/editor/contrib/find/test/findController.test.ts index 80d94fe719b56..81f2e6bf157ef 100644 --- a/src/vs/editor/contrib/find/test/findController.test.ts +++ b/src/vs/editor/contrib/find/test/findController.test.ts @@ -65,7 +65,7 @@ suite('FindController', () => { onWillSaveState: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - getInteger: (key: string) => undefined!, + getInteger: (key: string) => undefined, store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, remove: (key) => void 0 } as IStorageService); @@ -94,7 +94,7 @@ suite('FindController', () => { // I select ABC on the first line editor.setSelection(new Selection(1, 1, 1, 4)); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null!, editor); + startFindAction.run(null, editor); assert.deepEqual(findController.getGlobalBufferTerm(), findController.getState().searchString); findController.dispose(); @@ -119,10 +119,10 @@ suite('FindController', () => { let findState = findController.getState(); let nextMatchFindAction = new NextMatchFindAction(); - nextMatchFindAction.run(null!, editor); + nextMatchFindAction.run(null, editor); assert.equal(findState.searchString, 'ABC'); - assert.deepEqual(fromRange(editor.getSelection()!), [1, 1, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]); findController.dispose(); }); @@ -167,7 +167,7 @@ suite('FindController', () => { let nextMatchFindAction = new NextMatchFindAction(); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null!, editor); + startFindAction.run(null, editor); // I type ABC. findState.change({ searchString: 'A' }, true); @@ -175,14 +175,14 @@ suite('FindController', () => { findState.change({ searchString: 'ABC' }, true); // The first ABC is highlighted. - assert.deepEqual(fromRange(editor.getSelection()!), [1, 1, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]); // I hit Esc to exit the Find dialog. findController.closeFindWidget(); findController.hasFocus = false; // The cursor is now at end of the first line, with ABC on that line highlighted. - assert.deepEqual(fromRange(editor.getSelection()!), [1, 1, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]); // I hit delete to remove it and change the text to XYZ. editor.pushUndoStop(); @@ -195,13 +195,13 @@ suite('FindController', () => { // ABC // XYZ // ABC - assert.equal(editor.getModel()!.getLineContent(1), 'XYZ'); + assert.equal(editor.getModel().getLineContent(1), 'XYZ'); // The cursor is at end of the first line. - assert.deepEqual(fromRange(editor.getSelection()!), [1, 4, 1, 4]); + assert.deepEqual(fromRange(editor.getSelection()), [1, 4, 1, 4]); // I hit F3 to "Find Next" to find the next occurrence of ABC, but instead it searches for XYZ. - nextMatchFindAction.run(null!, editor); + nextMatchFindAction.run(null, editor); assert.equal(findState.searchString, 'ABC'); assert.equal(findController.hasFocus, false); @@ -223,11 +223,11 @@ suite('FindController', () => { column: 9 }); - nextMatchFindAction.run(null!, editor); - assert.deepEqual(fromRange(editor.getSelection()!), [1, 26, 1, 29]); + nextMatchFindAction.run(null, editor); + assert.deepEqual(fromRange(editor.getSelection()), [1, 26, 1, 29]); - nextMatchFindAction.run(null!, editor); - assert.deepEqual(fromRange(editor.getSelection()!), [1, 8, 1, 11]); + nextMatchFindAction.run(null, editor); + assert.deepEqual(fromRange(editor.getSelection()), [1, 8, 1, 11]); findController.dispose(); }); @@ -247,13 +247,13 @@ suite('FindController', () => { editor.setSelection(new Selection(1, 9, 1, 13)); findController.toggleRegex(); - startFindAction.run(null!, editor); + startFindAction.run(null, editor); - nextMatchFindAction.run(null!, editor); - assert.deepEqual(fromRange(editor.getSelection()!), [2, 9, 2, 13]); + nextMatchFindAction.run(null, editor); + assert.deepEqual(fromRange(editor.getSelection()), [2, 9, 2, 13]); - nextMatchFindAction.run(null!, editor); - assert.deepEqual(fromRange(editor.getSelection()!), [1, 9, 1, 13]); + nextMatchFindAction.run(null, editor); + assert.deepEqual(fromRange(editor.getSelection()), [1, 9, 1, 13]); findController.dispose(); }); @@ -278,8 +278,8 @@ suite('FindController', () => { shouldAnimate: false, updateSearchScope: false }); - nextMatchFindAction.run(null!, editor); - startFindReplaceAction.run(null!, editor); + nextMatchFindAction.run(null, editor); + startFindReplaceAction.run(null, editor); assert.equal(findController.getState().searchString, testRegexString); @@ -325,12 +325,12 @@ suite('FindController', () => { let findController = editor.registerAndInstantiateContribution(TestFindController); let startFindAction = new StartFindAction(); - startFindAction.run(null!, editor); + startFindAction.run(null, editor); findController.getState().change({ searchString: '\\b\\s{3}\\b', replaceString: ' ', isRegex: true }, false); findController.moveToNextMatch(); - assert.deepEqual(editor.getSelections()!.map(fromRange), [ + assert.deepEqual(editor.getSelections().map(fromRange), [ [1, 39, 1, 42] ]); @@ -352,12 +352,12 @@ suite('FindController', () => { let findController = editor.registerAndInstantiateContribution(TestFindController); let startFindAction = new StartFindAction(); - startFindAction.run(null!, editor); + startFindAction.run(null, editor); findController.getState().change({ searchString: '^', replaceString: 'x', isRegex: true }, false); findController.moveToNextMatch(); - assert.deepEqual(editor.getSelections()!.map(fromRange), [ + assert.deepEqual(editor.getSelections().map(fromRange), [ [2, 1, 2, 1] ]); @@ -386,9 +386,9 @@ suite('FindController', () => { editor.setSelection(new Selection(1, 1, 1, 9)); // cmd+f3 - nextSelectionMatchFindAction.run(null!, editor); + nextSelectionMatchFindAction.run(null, editor); - assert.deepEqual(editor.getSelections()!.map(fromRange), [ + assert.deepEqual(editor.getSelections().map(fromRange), [ [3, 1, 3, 9] ]); @@ -408,7 +408,7 @@ suite('FindController', () => { let nextSelectionMatchFindAction = new NextSelectionMatchFindAction(); // cmd+f - open find widget - startFindAction.run(null!, editor); + startFindAction.run(null, editor); // toggle regex findController.getState().change({ isRegex: true }, false); @@ -417,9 +417,9 @@ suite('FindController', () => { editor.setSelection(new Selection(1, 1, 1, 9)); // cmd+f3 - nextSelectionMatchFindAction.run(null!, editor); + nextSelectionMatchFindAction.run(null, editor); - assert.deepEqual(editor.getSelections()!.map(fromRange), [ + assert.deepEqual(editor.getSelections().map(fromRange), [ [3, 1, 3, 9] ]); @@ -440,7 +440,7 @@ suite('FindController query options persistence', () => { onWillSaveState: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - getInteger: (key: string) => undefined!, + getInteger: (key: string) => undefined, store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, remove: (key) => void 0 } as IStorageService); @@ -459,12 +459,12 @@ suite('FindController query options persistence', () => { let startFindAction = new StartFindAction(); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null!, editor); + startFindAction.run(null, editor); // I type ABC. findState.change({ searchString: 'ABC' }, true); // The second ABC is highlighted as matchCase is true. - assert.deepEqual(fromRange(editor.getSelection()!), [2, 1, 2, 4]); + assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 2, 4]); findController.dispose(); }); @@ -486,12 +486,12 @@ suite('FindController query options persistence', () => { let startFindAction = new StartFindAction(); // I hit Ctrl+F to show the Find dialog - startFindAction.run(null!, editor); + startFindAction.run(null, editor); // I type AB. findState.change({ searchString: 'AB' }, true); // The second AB is highlighted as wholeWord is true. - assert.deepEqual(fromRange(editor.getSelection()!), [2, 1, 2, 3]); + assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 2, 3]); findController.dispose(); }); diff --git a/src/vs/editor/standalone/test/browser/simpleServices.test.ts b/src/vs/editor/standalone/test/browser/simpleServices.test.ts index 160fa02625345..7154ac5e4f281 100644 --- a/src/vs/editor/standalone/test/browser/simpleServices.test.ts +++ b/src/vs/editor/standalone/test/browser/simpleServices.test.ts @@ -15,7 +15,7 @@ suite('StandaloneKeybindingService', () => { class TestStandaloneKeybindingService extends StandaloneKeybindingService { public testDispatch(e: IKeyboardEvent): void { - super._dispatch(e, null!); + super._dispatch(e, null); } } @@ -47,7 +47,7 @@ suite('StandaloneKeybindingService', () => { altKey: false, metaKey: false, keyCode: KeyCode.F9, - code: null! + code: null }); assert.ok(commandInvoked, 'command invoked'); diff --git a/src/vs/platform/commands/test/commands.test.ts b/src/vs/platform/commands/test/commands.test.ts index 054c0ff499780..3ec89a65d3a64 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/contextkey/test/common/contextkey.test.ts b/src/vs/platform/contextkey/test/common/contextkey.test.ts index cb12470e3c287..cec230cc148f5 100644 --- a/src/vs/platform/contextkey/test/common/contextkey.test.ts +++ b/src/vs/platform/contextkey/test/common/contextkey.test.ts @@ -50,10 +50,10 @@ suite('ContextKeyExpr', () => { let key1IsFalse = ContextKeyExpr.equals('key1', false); let key1IsNotTrue = ContextKeyExpr.notEquals('key1', true); - assert.ok(key1IsTrue.normalize()!.equals(ContextKeyExpr.has('key1'))); - assert.ok(key1IsNotFalse.normalize()!.equals(ContextKeyExpr.has('key1'))); - assert.ok(key1IsFalse.normalize()!.equals(ContextKeyExpr.not('key1'))); - assert.ok(key1IsNotTrue.normalize()!.equals(ContextKeyExpr.not('key1'))); + assert.ok(key1IsTrue.normalize().equals(ContextKeyExpr.has('key1'))); + assert.ok(key1IsNotFalse.normalize().equals(ContextKeyExpr.has('key1'))); + assert.ok(key1IsFalse.normalize().equals(ContextKeyExpr.not('key1'))); + assert.ok(key1IsNotTrue.normalize().equals(ContextKeyExpr.not('key1'))); }); test('evaluate', () => { @@ -67,7 +67,7 @@ suite('ContextKeyExpr', () => { function testExpression(expr: string, expected: boolean): void { // console.log(expr + ' ' + expected); let rules = ContextKeyExpr.deserialize(expr); - assert.equal(rules!.evaluate(context), expected, expr); + assert.equal(rules.evaluate(context), expected, expr); } function testBatch(expr: string, value: any): void { testExpression(expr, !!value); diff --git a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts index 1a3107370cb49..d75b1cbdec545 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/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts b/src/vs/workbench/services/files/node/watcher/unix/test/chockidarWatcherService.test.ts index e73689a691b42..180de3e850eff 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: string[] = []): IWatcherRequest { +function newRequest(basePath: string, ignored = []): IWatcherRequest { return { basePath, ignored }; } @@ -127,7 +127,7 @@ suite.skip('Chockidar watching', () => { const service = new ChokidarWatcherService(); const result: IRawFileChange[] = []; - let error: string | null = null; + let error = null; suiteSetup(async () => { await pfs.mkdirp(testDir); diff --git a/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts b/src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts index 18cf13242e91b..0e0c5c7beada3 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', () => { @@ -1127,7 +1127,7 @@ suite('keyboardMapper - LINUX en_us', () => { assertResolveUserBinding( mapper, new ScanCodeBinding(true, false, false, false, ScanCode.Comma), - null!, + null, [{ label: 'Ctrl+,', ariaLabel: 'Control+,', @@ -1224,7 +1224,7 @@ suite('keyboardMapper', () => { test('issue #24064: NumLock/NumPad keys stopped working in 1.11 on Linux', () => { let mapper = new MacLinuxKeyboardMapper(false, {}, OperatingSystem.Linux); - function assertNumpadKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string | null, userSettingsLabel: string, dispatch: string): void { + function assertNumpadKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string, userSettingsLabel: string, dispatch: string): void { assertResolveKeyboardEvent( mapper, { @@ -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) {