diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 1961c4ea5fc5f1b349d144fe1f0de7b029bcb436..4b736b362216604d00ec9f97dbd2ef89ac9dc752 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -63,6 +63,7 @@ "./vs/base/node/ports.ts", "./vs/base/node/processes.ts", "./vs/base/node/proxy.ts", + "./vs/base/node/ps.ts", "./vs/base/node/request.ts", "./vs/base/node/stats.ts", "./vs/base/node/storage.ts", @@ -70,7 +71,9 @@ "./vs/base/parts/contextmenu/common/contextmenu.ts", "./vs/base/parts/contextmenu/electron-browser/contextmenu.ts", "./vs/base/parts/contextmenu/electron-main/contextmenu.ts", + "./vs/base/parts/ipc/node/ipc.cp.ts", "./vs/base/parts/ipc/node/ipc.ts", + "./vs/base/parts/ipc/test/node/testApp.ts", "./vs/base/parts/ipc/test/node/testService.ts", "./vs/base/parts/quickopen/common/quickOpen.ts", "./vs/base/test/browser/ui/grid/util.ts", @@ -347,12 +350,14 @@ "./vs/nls.d.ts", "./vs/nls.mock.ts", "./vs/platform/actions/common/actions.ts", + "./vs/platform/actions/common/menu.ts", "./vs/platform/backup/common/backup.ts", "./vs/platform/broadcast/electron-browser/broadcastService.ts", "./vs/platform/clipboard/common/clipboardService.ts", "./vs/platform/clipboard/electron-browser/clipboardService.ts", "./vs/platform/commands/common/commands.ts", "./vs/platform/configuration/common/configuration.ts", + "./vs/platform/configuration/common/configurationModels.ts", "./vs/platform/configuration/common/configurationRegistry.ts", "./vs/platform/contextkey/browser/contextKeyService.ts", "./vs/platform/contextkey/common/contextkey.ts", @@ -489,9 +494,11 @@ "./vs/workbench/parts/scm/common/scm.ts", "./vs/workbench/parts/scm/electron-browser/scmUtil.ts", "./vs/workbench/parts/search/common/constants.ts", + "./vs/workbench/parts/search/common/queryBuilder.ts", "./vs/workbench/parts/surveys/electron-browser/nps.contribution.ts", "./vs/workbench/parts/tasks/common/problemMatcher.ts", "./vs/workbench/parts/tasks/common/taskTemplates.ts", + "./vs/workbench/parts/tasks/electron-browser/jsonSchemaCommon.ts", "./vs/workbench/parts/terminal/browser/terminalWidgetManager.ts", "./vs/workbench/parts/terminal/common/terminal.ts", "./vs/workbench/parts/terminal/common/terminalColorRegistry.ts", @@ -504,6 +511,7 @@ "./vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts", "./vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page.ts", "./vs/workbench/parts/welcome/walkThrough/node/walkThroughUtils.ts", + "./vs/workbench/services/actions/common/menuService.ts", "./vs/workbench/services/activity/common/activity.ts", "./vs/workbench/services/backup/common/backup.ts", "./vs/workbench/services/commands/common/commandService.ts", @@ -536,6 +544,7 @@ "./vs/workbench/services/progress/common/progress.ts", "./vs/workbench/services/scm/common/scm.ts", "./vs/workbench/services/scm/common/scmService.ts", + "./vs/workbench/services/search/node/legacy/search.ts", "./vs/workbench/services/search/node/search.ts", "./vs/workbench/services/search/node/searchHistoryService.ts", "./vs/workbench/services/search/node/searchIpc.ts", diff --git a/src/vs/base/node/encoding.ts b/src/vs/base/node/encoding.ts index 3b7c4235f6765389d906a20fe965f73f1066171a..c1d248beb48ad48cd01025ff13aa39fb373a4341 100644 --- a/src/vs/base/node/encoding.ts +++ b/src/vs/base/node/encoding.ts @@ -63,7 +63,7 @@ export function toDecodeStream(readable: Readable, options: IDecodeStreamOptions // waiting for the decoder to be ready this._decodeStreamConstruction.then(_ => callback(), err => callback(err)); - } else if (this._bytesBuffered >= options.minBytesRequiredForDetection) { + } else if (typeof options.minBytesRequiredForDetection === 'number' && this._bytesBuffered >= options.minBytesRequiredForDetection) { // buffered enough data, create stream and forward data this._startDecodeStream(callback); diff --git a/src/vs/base/node/ps.ts b/src/vs/base/node/ps.ts index af7e3cf162a81aa023e36ec5b62f362a831ee496..a11b552b85154f993bf9e761ae42a08f7b831d22 100644 --- a/src/vs/base/node/ps.ts +++ b/src/vs/base/node/ps.ts @@ -137,14 +137,14 @@ export function listProcesses(rootPid: number): Promise { windowsProcessTree.getProcessCpuUsage(processList, (completeProcessList) => { const processItems: Map = new Map(); completeProcessList.forEach(process => { - const commandLine = cleanUNCPrefix(process.commandLine); + const commandLine = cleanUNCPrefix(process.commandLine || ''); processItems.set(process.pid, { name: findName(commandLine), cmd: commandLine, pid: process.pid, ppid: process.ppid, - load: process.cpu, - mem: process.memory + load: process.cpu || 0, + mem: process.memory || 0 }); }); @@ -197,9 +197,11 @@ export function listProcesses(rootPid: number): Promise { const pids: number[] = []; while (processes.length) { const process = processes.shift(); - pids.push(process.pid); - if (process.children) { - processes = processes.concat(process.children); + if (process) { + pids.push(process.pid); + if (process.children) { + processes = processes.concat(process.children); + } } } diff --git a/src/vs/base/parts/ipc/node/ipc.cp.ts b/src/vs/base/parts/ipc/node/ipc.cp.ts index 9812c24e2d4ba3ce6b35a9bca275703ae29ffa27..0d0f2c0016659243a84f7b7f7894367456250d19 100644 --- a/src/vs/base/parts/ipc/node/ipc.cp.ts +++ b/src/vs/base/parts/ipc/node/ipc.cp.ts @@ -22,7 +22,13 @@ import * as errors from 'vs/base/common/errors'; export class Server extends IPCServer { constructor() { super({ - send: r => { try { process.send(r.toString('base64')); } catch (e) { /* not much to do */ } }, + send: r => { + try { + if (process.send) { + process.send(r.toString('base64')); + } + } catch (e) { /* not much to do */ } + }, onMessage: fromNodeEventEmitter(process, 'message', msg => Buffer.from(msg, 'base64')) }); @@ -81,8 +87,8 @@ export class Client implements IChannelClient, IDisposable { private disposeDelayer: Delayer; private activeRequests = new Set(); - private child: ChildProcess; - private _client: IPCClient; + private child: ChildProcess | null; + private _client: IPCClient | null; private channels = new Map(); private _onDidProcessExit = new Emitter<{ code: number, signal: string }>(); @@ -200,7 +206,7 @@ export class Client implements IChannelClient, IDisposable { // Handle remote console logs specially if (isRemoteConsoleLog(msg)) { log(msg, `IPC Library: ${this.options.serverName}`); - return null; + return; } // Anything else goes to the outside @@ -253,8 +259,10 @@ export class Client implements IChannelClient, IDisposable { private disposeClient() { if (this._client) { - this.child.kill(); - this.child = null; + if (this.child) { + this.child.kill(); + this.child = null; + } this._client = null; this.channels.clear(); } @@ -263,7 +271,7 @@ export class Client implements IChannelClient, IDisposable { dispose() { this._onDidProcessExit.dispose(); this.disposeDelayer.cancel(); - this.disposeDelayer = null; + this.disposeDelayer = null!; // StrictNullOverride: nulling out ok in dispose this.disposeClient(); this.activeRequests.clear(); } diff --git a/src/vs/platform/actions/common/menu.ts b/src/vs/platform/actions/common/menu.ts index d90656347f8d58c678f36e7347f2d112c274a00d..9b7212efcaa3ff24c37028a5117843da45804af4 100644 --- a/src/vs/platform/actions/common/menu.ts +++ b/src/vs/platform/actions/common/menu.ts @@ -27,17 +27,17 @@ export class Menu implements IMenu { const menuItems = MenuRegistry.getMenuItems(id); const keysFilter = new Set(); - let group: MenuItemGroup; + let group: MenuItemGroup | undefined; menuItems.sort(Menu._compareMenuItems); for (let item of menuItems) { // group by groupId const groupName = item.group; if (!group || group[0] !== groupName) { - group = [groupName, []]; + group = [groupName || '', []]; this._menuGroups.push(group); } - group[1].push(item); + group![1].push(item); // keep keys for eventing Menu._fillInKbExprKeys(item.when, keysFilter); @@ -79,7 +79,7 @@ export class Menu implements IMenu { const [id, items] = group; const activeActions: (MenuItemAction | SubmenuItemAction)[] = []; for (const item of items) { - if (this._contextKeyService.contextMatchesRules(item.when)) { + if (this._contextKeyService.contextMatchesRules(item.when || null)) { const action = isIMenuItem(item) ? new MenuItemAction(item.command, item.alt, options, this._contextKeyService, this._commandService) : new SubmenuItemAction(item); activeActions.push(action); } @@ -91,7 +91,7 @@ export class Menu implements IMenu { return result; } - private static _fillInKbExprKeys(exp: ContextKeyExpr, set: Set): void { + private static _fillInKbExprKeys(exp: ContextKeyExpr | undefined, set: Set): void { if (exp) { for (let key of exp.keys()) { set.add(key); diff --git a/src/vs/platform/configuration/common/configurationModels.ts b/src/vs/platform/configuration/common/configurationModels.ts index 1cf0e148edb53c075fb9b651e3903f348f0bbe87..b332c2b18b32dc803f43dcd5f5fd9e098a898c25 100644 --- a/src/vs/platform/configuration/common/configurationModels.ts +++ b/src/vs/platform/configuration/common/configurationModels.ts @@ -320,8 +320,8 @@ export class Configuration { inspect(key: string, overrides: IConfigurationOverrides, workspace: Workspace): { default: C, user: C, - workspace: C, - workspaceFolder: C + workspace?: C, + workspaceFolder?: C memory?: C value: C, } { @@ -344,7 +344,7 @@ export class Configuration { workspace: string[]; workspaceFolder: string[]; } { - const folderConfigurationModel = this.getFolderConfigurationModelForResource(null, workspace); + const folderConfigurationModel = this.getFolderConfigurationModelForResource(undefined, workspace); return { default: this._defaultConfiguration.freeze().keys, user: this._userConfiguration.freeze().keys, @@ -447,7 +447,7 @@ export class Configuration { return folderConsolidatedConfiguration; } - private getFolderConfigurationModelForResource(resource: URI, workspace: Workspace): ConfigurationModel { + private getFolderConfigurationModelForResource(resource: URI | undefined, workspace: Workspace): ConfigurationModel | null { if (workspace && resource) { const root = workspace.getFolder(resource); if (root) { diff --git a/src/vs/workbench/parts/search/common/queryBuilder.ts b/src/vs/workbench/parts/search/common/queryBuilder.ts index c3e134aaae07316390464e0260949424be447cb9..202b704d4de1e6a21bd95ce7ddaf902b1adcdcc4 100644 --- a/src/vs/workbench/parts/search/common/queryBuilder.ts +++ b/src/vs/workbench/parts/search/common/queryBuilder.ts @@ -86,7 +86,7 @@ export class QueryBuilder { }; } - file(folderResources?: uri[], options?: IFileQueryBuilderOptions): IFileQuery { + file(folderResources: uri[] | undefined, options: IFileQueryBuilderOptions): IFileQuery { const commonQuery = this.commonQuery(folderResources, options); return { ...commonQuery, @@ -101,8 +101,8 @@ export class QueryBuilder { } private commonQuery(folderResources?: uri[], options: ICommonQueryBuilderOptions = {}): ICommonQueryProps { - let { searchPaths, pattern: includePattern } = this.parseSearchPaths(options.includePattern); - let excludePattern = this.parseExcludePattern(options.excludePattern); + let { searchPaths, pattern: includePattern } = this.parseSearchPaths(options.includePattern || ''); + let excludePattern = this.parseExcludePattern(options.excludePattern || ''); // Build folderQueries from searchPaths, if given, otherwise folderResources let folderQueries = folderResources && folderResources.map(uri => this.getFolderQueryForRoot(uri, options)); @@ -153,7 +153,7 @@ export class QueryBuilder { } } - return contentPattern.isCaseSensitive; + return !!contentPattern.isCaseSensitive; } private isMultiline(contentPattern: IPatternInfo): boolean { @@ -364,7 +364,7 @@ function splitGlobFromPath(searchPath: string): { pathPortion: string, globPorti return { pathPortion, - globPortion: searchPath.substr(lastSlashMatch.index + 1) + globPortion: searchPath.substr((lastSlashMatch.index || 0) + 1) }; } }