diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5db8fb3fbc..718587cb00 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -42,6 +42,20 @@ "applyTo": "allDocuments" } }, + { + "type": "npm", + "script": "strict-null-check-watch", + "label": "TS - Strict Null Cheks", + "isBackground": true, + "presentation": { + "reveal": "never" + }, + "problemMatcher": { + "base": "$tsc-watch", + "owner": "typescript-strict-null-checks", + "applyTo": "allDocuments" + } + }, { "type": "gulp", "task": "tslint", diff --git a/azure-pipelines-linux-mac.yml b/azure-pipelines-linux-mac.yml index 2354f5857d..e7e10a8560 100644 --- a/azure-pipelines-linux-mac.yml +++ b/azure-pipelines-linux-mac.yml @@ -35,9 +35,9 @@ steps: yarn tslint displayName: 'Run TSLint' -# - script: | -# yarn strict-null-check -# displayName: 'Run Strict Null Check' +- script: | + yarn strict-null-check + displayName: 'Run Strict Null Check' - script: | yarn compile diff --git a/azure-pipelines-windows.yml b/azure-pipelines-windows.yml index ab9beec255..74bed5ab3a 100644 --- a/azure-pipelines-windows.yml +++ b/azure-pipelines-windows.yml @@ -20,9 +20,9 @@ steps: yarn tslint displayName: 'Run TSLint' -# - script: | -# yarn strict-null-check -# displayName: 'Run Strict Null Check' +- script: | + yarn strict-null-check + displayName: 'Run Strict Null Check' - script: | yarn compile diff --git a/src/sql/base/browser/ui/table/formatters.ts b/src/sql/base/browser/ui/table/formatters.ts index 971157d195..7c78fa8453 100644 --- a/src/sql/base/browser/ui/table/formatters.ts +++ b/src/sql/base/browser/ui/table/formatters.ts @@ -18,7 +18,7 @@ export class DBCellValue { /** * Format xml field into a hyperlink and performs HTML entity encoding */ -export function hyperLinkFormatter(row: number, cell: any, value: any, columnDef: any, dataContext: any): string { +export function hyperLinkFormatter(row: number | undefined, cell: any | undefined, value: any, columnDef: any | undefined, dataContext: any | undefined): string { let cellClasses = 'grid-cell-value-container'; let valueToDisplay: string = ''; @@ -38,7 +38,7 @@ export function hyperLinkFormatter(row: number, cell: any, value: any, columnDef /** * Format all text to replace all new lines with spaces and performs HTML entity encoding */ -export function textFormatter(row: number, cell: any, value: any, columnDef: any, dataContext: any): string { +export function textFormatter(row: number | undefined, cell: any | undefined, value: any, columnDef: any | undefined, dataContext: any | undefined): string { let cellClasses = 'grid-cell-value-container'; let valueToDisplay = ''; let titleValue = ''; diff --git a/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts b/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts index ff3645c5f2..5dbe563c8e 100644 --- a/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts +++ b/src/sql/platform/telemetry/test/common/telemetryUtilities.test.ts @@ -22,7 +22,7 @@ suite('SQL Telemetry Utilities tests', () => { serverName: '', authenticationType: '', getOptionsKey: () => '', - matches: undefined, + matches: () => false, groupFullName: '', groupId: '', id: '', @@ -44,7 +44,7 @@ suite('SQL Telemetry Utilities tests', () => { }; const logService = new NullLogService(); TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { - telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b.provider === providerName)), TypeMoq.Times.once()); + telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b!.provider === providerName)), TypeMoq.Times.once()); done(); }).catch(err => { assert.fail(err); @@ -63,11 +63,11 @@ suite('SQL Telemetry Utilities tests', () => { TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { telemetryService.verify(x => x.publicLog( TypeMoq.It.is(a => a === telemetryKey), - TypeMoq.It.is(b => b.provider === providerName - && b.from === data.from - && b.target === data.target - && b.test1 === data.test1 - && b.connection === undefined)), TypeMoq.Times.once()); + TypeMoq.It.is(b => b!.provider === providerName + && b!.from === data.from + && b!.target === data.target + && b!.test1 === data.test1 + && b!.connection === undefined)), TypeMoq.Times.once()); done(); }).catch(err => { assert.fail(err); @@ -97,7 +97,7 @@ suite('SQL Telemetry Utilities tests', () => { const logService = new NullLogService(); TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { - telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b.provider === data.provider)), TypeMoq.Times.once()); + telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b!.provider === data.provider)), TypeMoq.Times.once()); done(); }).catch(err => { assert.fail(err); diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 48384d5f26..547e24ef50 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -5,7 +5,7 @@ "strictNullChecks": true, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, - "moduleResolution": "classic" + "skipLibCheck": true }, "include": [ "./typings", @@ -22,8 +22,5 @@ "./sql/platform/credentials/**/*.ts", "./sql/platform/theme/**/*.ts", "./sql/platform/telemetry/**/*.ts" - ], - "exclude": [ - "node_modules/**" ] } diff --git a/src/vs/base/common/arrays.ts b/src/vs/base/common/arrays.ts index 9821106225..4f96e3b4f4 100644 --- a/src/vs/base/common/arrays.ts +++ b/src/vs/base/common/arrays.ts @@ -297,7 +297,7 @@ function topStep(array: ReadonlyArray, compare: (a: T, b: T) => number, re */ export function coalesce(array: ReadonlyArray): T[] { if (!array) { - return undefined; // {{SQL CARBON EDIT}} @anthonydresser strict-null-checks + return array as T[]; // {{SQL CARBON EDIT}} @anthonydresser strict-null-checks } return array.filter(e => !!e); } diff --git a/src/vs/platform/product/browser/productService.ts b/src/vs/platform/product/browser/productService.ts index ac49b82bf8..1a46cd6412 100644 --- a/src/vs/platform/product/browser/productService.ts +++ b/src/vs/platform/product/browser/productService.ts @@ -21,7 +21,7 @@ export class ProductService implements IProductService { get vscodeVersion(): string { return '1.35.0'; } // {{SQL CARBON EDIT}} add vscodeversion - get recommendedExtensionsByScenario(): { [area: string]: Array } { return this.productConfiguration.recommendedExtensionsByScenario; }// {{SQL CARBON EDIT}} add getter + get recommendedExtensionsByScenario(): { [area: string]: Array } { return this.productConfiguration ? this.productConfiguration.recommendedExtensionsByScenario : {}; }// {{SQL CARBON EDIT}} add getter get commit(): string | undefined { return this.productConfiguration ? this.productConfiguration.commit : undefined; } diff --git a/src/vs/platform/telemetry/node/appInsightsAppender.ts b/src/vs/platform/telemetry/node/appInsightsAppender.ts index 2954780b44..59415e88d5 100644 --- a/src/vs/platform/telemetry/node/appInsightsAppender.ts +++ b/src/vs/platform/telemetry/node/appInsightsAppender.ts @@ -73,7 +73,7 @@ export class AppInsightsAppender implements ITelemetryAppender { }); } - flush(): Promise | undefined { + flush(): Promise { if (this._aiClient) { return new Promise(resolve => { this._aiClient!.flush({ @@ -85,6 +85,6 @@ export class AppInsightsAppender implements ITelemetryAppender { }); }); } - return undefined; + return Promise.resolve(undefined); } }