diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 59484266c7b7d..993f4be1ed353 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -845,7 +845,35 @@ "./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/tree/asyncDataTree.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/platform/configuration/test/common/configurationModels.test.ts", + "./vs/platform/extensions/test/node/extensionValidator.test.ts", + "./vs/platform/instantiation/test/common/instantiationService.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/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/keybinding/test/keybindingIO.test.ts", + "./vs/workbench/services/keybinding/test/macLinuxFallbackKeyboardMapper.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" ], "exclude": [ 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/tree/test/browser/treeModel.test.ts b/src/vs/base/parts/tree/test/browser/treeModel.test.ts index 03c321bb0ded5..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): () => 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/base/test/common/arrays.test.ts b/src/vs/base/test/common/arrays.test.ts index 38a235ea87163..1226465c6129b 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/history.test.ts b/src/vs/base/test/common/history.test.ts index 9c93a0adeb518..fc32e74324be0 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/node/extfs/extfs.test.ts b/src/vs/base/test/node/extfs/extfs.test.ts index b540aab4aae8b..100de754c29e7 100644 --- a/src/vs/base/test/node/extfs/extfs.test.ts +++ b/src/vs/base/test/node/extfs/extfs.test.ts @@ -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/code/test/node/windowsFinder.test.ts b/src/vs/code/test/node/windowsFinder.test.ts index bd9e7ee187afb..270a7dc04c99e 100644 --- a/src/vs/code/test/node/windowsFinder.test.ts +++ b/src/vs/code/test/node/windowsFinder.test.ts @@ -25,7 +25,7 @@ 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 }; } 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/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/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 dbfa241c96d3d..ff67a7ea552ad 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/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 df05ef60d0db2..ba390e1ff497e 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -491,7 +491,7 @@ export class TextEdit { constructor(range: Range, newText: string) { 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 5e7a6163c18d1..4502bf9a2f95f 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/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/test/electron-browser/api/extHostTypes.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts index 6e121e81c9228..d2deeaf2163d5 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,18 +325,18 @@ 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', () => { 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, ''); @@ -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 () {