diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 978ecdd42b861..afa7acafa9401 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { spawn, ChildProcess } from 'child_process'; +import { spawn, ChildProcess, SpawnOptions } from 'child_process'; import { assign } from 'vs/base/common/objects'; import { buildHelpMessage, buildVersionMessage, addArg, createWaitMarkerFile } from 'vs/platform/environment/node/argv'; import { parseCLIProcessArgv } from 'vs/platform/environment/node/argvHelper'; @@ -19,6 +19,7 @@ import { resolveTerminalEncoding } from 'vs/base/node/encoding'; import * as iconv from 'iconv-lite'; import { isWindows } from 'vs/base/common/platform'; import { ProfilingSession, Target } from 'v8-inspect-profiler'; +import { isString } from 'vs/base/common/types'; function shouldSpawnCliProcess(argv: ParsedArgs): boolean { return !!argv['install-source'] @@ -339,14 +340,15 @@ export async function main(argv: string[]): Promise { }); } - if (args['js-flags']) { - const match = /max_old_space_size=(\d+)/g.exec(args['js-flags']); + const jsFlags = args['js-flags']; + if (isString(jsFlags)) { + const match = /max_old_space_size=(\d+)/g.exec(jsFlags); if (match && !args['max-memory']) { addArg(argv, `--max-memory=${match[1]}`); } } - const options = { + const options: SpawnOptions = { detached: true, env }; diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index 69ab16d03f727..9446ef00d59f7 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -85,7 +85,7 @@ export class Main { } else if (argv['install-extension']) { const arg = argv['install-extension']; const args: string[] = typeof arg === 'string' ? [arg] : arg; - await this.installExtensions(args, argv['force']); + await this.installExtensions(args, !!argv['force']); } else if (argv['uninstall-extension']) { const arg = argv['uninstall-extension']; diff --git a/src/vs/editor/contrib/folding/foldingModel.ts b/src/vs/editor/contrib/folding/foldingModel.ts index 0375be9f13f3e..70906b653eb43 100644 --- a/src/vs/editor/contrib/folding/foldingModel.ts +++ b/src/vs/editor/contrib/folding/foldingModel.ts @@ -47,7 +47,7 @@ export class FoldingModel { if (!regions.length) { return; } - let processed = {}; + let processed: { [key: string]: boolean | undefined } = {}; this._decorationProvider.changeDecorations(accessor => { for (let region of regions) { let index = region.regionIndex; diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index dc75380ba1868..2d2fdbb51cc00 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -71,6 +71,9 @@ export interface ParsedArgs { 'disable-user-env-probe'?: boolean; 'enable-remote-auto-shutdown'?: boolean; 'disable-inspect'?: boolean; + 'force'?: boolean; + 'js-flags'?: boolean; + 'gitCredential'?: string; } export const IEnvironmentService = createDecorator('environmentService'); diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index f78e5d7cc621e..3cdfd35e4173f 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -14,11 +14,11 @@ import { writeFileSync } from 'vs/base/node/pfs'; * This code is also used by standalone cli's. Avoid adding any other dependencies. */ -class HelpCategories { - o = localize('optionsUpperCase', "Options"); - e = localize('extensionsManagement', "Extensions Management"); - t = localize('troubleshooting', "Troubleshooting"); -} +const helpCategories = { + o: localize('optionsUpperCase', "Options"), + e: localize('extensionsManagement', "Extensions Management"), + t: localize('troubleshooting', "Troubleshooting") +}; export interface Option { id: string; @@ -27,7 +27,7 @@ export interface Option { deprecates?: string; // old deprecated id args?: string | string[]; description?: string; - cat?: keyof HelpCategories; + cat?: keyof typeof helpCategories; } export const options: Option[] = [ @@ -94,6 +94,7 @@ export const options: Option[] = [ { id: 'trace-category-filter', type: 'string' }, { id: 'trace-options', type: 'string' }, { id: 'prof-code-loading', type: 'boolean' }, + { id: 'js-flags', type: 'string' }, { id: '_', type: 'string' } ]; @@ -189,8 +190,6 @@ function wrapText(text: string, columns: number): string[] { export function buildHelpMessage(productName: string, executableName: string, version: string, isOptionSupported = (_: Option) => true, isPipeSupported = true): string { const columns = (process.stdout).isTTY && (process.stdout).columns || 80; - let categories = new HelpCategories(); - let help = [`${productName} ${version}`]; help.push(''); help.push(`${localize('usage', "Usage")}: ${executableName} [${localize('options', "options")}][${localize('paths', 'paths')}...]`); @@ -203,10 +202,12 @@ export function buildHelpMessage(productName: string, executableName: string, ve } help.push(''); } - for (const key in categories) { + for (let helpCategoryKey in helpCategories) { + const key = helpCategoryKey; + let categoryOptions = options.filter(o => !!o.description && o.cat === key && isOptionSupported(o)); if (categoryOptions.length) { - help.push(categories[key as keyof HelpCategories]); + help.push(helpCategories[key]); help.push(...formatOptions(categoryOptions, columns)); help.push(''); } diff --git a/src/vs/platform/history/common/history.ts b/src/vs/platform/history/common/history.ts index 2d7a8e0861184..d2ea48abad143 100644 --- a/src/vs/platform/history/common/history.ts +++ b/src/vs/platform/history/common/history.ts @@ -34,15 +34,15 @@ export interface IRecentFile { } export function isRecentWorkspace(curr: IRecent): curr is IRecentWorkspace { - return !!curr['workspace']; + return curr.hasOwnProperty('workspace'); } export function isRecentFolder(curr: IRecent): curr is IRecentFolder { - return !!curr['folderUri']; + return curr.hasOwnProperty('folderUri'); } export function isRecentFile(curr: IRecent): curr is IRecentFile { - return !!curr['fileUri']; + return curr.hasOwnProperty('fileUri'); } diff --git a/src/vs/platform/history/common/historyStorage.ts b/src/vs/platform/history/common/historyStorage.ts index c9175cdb9194f..2d5f47f398170 100644 --- a/src/vs/platform/history/common/historyStorage.ts +++ b/src/vs/platform/history/common/historyStorage.ts @@ -21,6 +21,14 @@ interface ILegacySerializedRecentlyOpened { interface ISerializedWorkspace { id: string; configURIPath: string; } interface ILegacySerializedWorkspace { id: string; configPath: string; } +function isLegacySerializedWorkspace(curr: any): curr is ILegacySerializedWorkspace { + return typeof curr === 'object' && typeof curr['id'] === 'string' && typeof curr['configPath'] === 'string'; +} + +function isUriComponents(curr: any): curr is UriComponents { + return curr && typeof curr['path'] === 'string' && typeof curr['scheme'] === 'string'; +} + export type RecentlyOpenedStorageData = object; export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefined): IRecentlyOpened { @@ -51,9 +59,9 @@ export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefine for (const workspace of storedRecents.workspaces) { if (typeof workspace === 'string') { result.workspaces.push({ folderUri: URI.file(workspace) }); - } else if (typeof workspace === 'object' && typeof workspace['id'] === 'string' && typeof workspace['configPath'] === 'string') { - result.workspaces.push({ workspace: { id: workspace['id'], configPath: URI.file(workspace['configPath']) } }); - } else if (workspace && typeof workspace['path'] === 'string' && typeof workspace['scheme'] === 'string') { + } else if (isLegacySerializedWorkspace(workspace)) { + result.workspaces.push({ workspace: { id: workspace.id, configPath: URI.file(workspace.configPath) } }); + } else if (isUriComponents(window)) { // added by 1.26-insiders result.workspaces.push({ folderUri: URI.revive(workspace) }); } diff --git a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts index afb4012f4f32f..5026e50adad76 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts @@ -181,7 +181,7 @@ interface ThemeItem { } function isItem(i: QuickPickInput): i is ThemeItem { - return i['type'] !== 'separatpr'; + return (i)['type'] !== 'separator'; } function toEntries(themes: Array, label?: string): QuickPickInput[] { @@ -212,7 +212,7 @@ class GenerateColorThemeAction extends Action { let theme = this.themeService.getColorTheme(); let colors = Registry.as(ColorRegistryExtensions.ColorContribution).getColors(); let colorIds = colors.map(c => c.id).sort(); - let resultingColors = {}; + let resultingColors: { [key: string]: string } = {}; let inherited: string[] = []; for (let colorId of colorIds) { const color = theme.getColor(colorId, false); diff --git a/src/vs/workbench/services/themes/common/colorThemeData.ts b/src/vs/workbench/services/themes/common/colorThemeData.ts index 08253f09445cd..6d39ebd157edf 100644 --- a/src/vs/workbench/services/themes/common/colorThemeData.ts +++ b/src/vs/workbench/services/themes/common/colorThemeData.ts @@ -23,7 +23,7 @@ import { startsWith } from 'vs/base/common/strings'; let colorRegistry = Registry.as(Extensions.ColorContribution); -const tokenGroupToScopesMap: { [setting: string]: string[] } = { +const tokenGroupToScopesMap = { comments: ['comment'], strings: ['string'], keywords: ['keyword - keyword.operator', 'keyword.control', 'storage', 'storage.type'], @@ -146,10 +146,11 @@ export class ColorThemeData implements IColorTheme { // Put the general customizations such as comments, strings, etc. first so that // they can be overridden by specific customizations like "string.interpolated" for (let tokenGroup in tokenGroupToScopesMap) { - let value = customTokenColors[tokenGroup]; + const group = tokenGroup; // TS doesn't type 'tokenGroup' properly + let value = customTokenColors[group]; if (value) { let settings = typeof value === 'string' ? { foreground: value } : value; - let scopes = tokenGroupToScopesMap[tokenGroup]; + let scopes = tokenGroupToScopesMap[group]; for (let scope of scopes) { this.customTokenColors.push({ scope, settings }); } @@ -186,7 +187,7 @@ export class ColorThemeData implements IColorTheme { } toStorageData() { - let colorMapData = {}; + let colorMapData: { [key: string]: string } = {}; for (let key in this.colorMap) { colorMapData[key] = Color.Format.CSS.formatHexA(this.colorMap[key], true); } diff --git a/src/vs/workbench/services/themes/common/fileIconThemeData.ts b/src/vs/workbench/services/themes/common/fileIconThemeData.ts index 306d58f9155e1..efdaaaef68cd1 100644 --- a/src/vs/workbench/services/themes/common/fileIconThemeData.ts +++ b/src/vs/workbench/services/themes/common/fileIconThemeData.ts @@ -366,5 +366,5 @@ function _processIconThemeDocument(id: string, iconThemeDocumentLocation: URI, i return result; } function escapeCSS(str: string) { - return window['CSS'].escape(str); + return (window)['CSS'].escape(str); } diff --git a/src/vs/workbench/services/themes/common/plistParser.ts b/src/vs/workbench/services/themes/common/plistParser.ts index e4478a5ecf6e9..6825c65147b2f 100644 --- a/src/vs/workbench/services/themes/common/plistParser.ts +++ b/src/vs/workbench/services/themes/common/plistParser.ts @@ -143,7 +143,7 @@ function _parse(content: string, filename: string | null, locationKeyName: strin if (curKey === null) { return fail('missing '); } - let newDict = {}; + let newDict: { [key: string]: any } = {}; if (locationKeyName !== null) { newDict[locationKeyName] = { filename: filename, @@ -168,7 +168,7 @@ function _parse(content: string, filename: string | null, locationKeyName: strin const arrState = { enterDict: function () { - let newDict = {}; + let newDict: { [key: string]: any } = {}; if (locationKeyName !== null) { newDict[locationKeyName] = { filename: filename, diff --git a/src/vs/workbench/services/themes/common/themeCompatibility.ts b/src/vs/workbench/services/themes/common/themeCompatibility.ts index 577b32e42068d..6518ff4a4acbf 100644 --- a/src/vs/workbench/services/themes/common/themeCompatibility.ts +++ b/src/vs/workbench/services/themes/common/themeCompatibility.ts @@ -26,7 +26,8 @@ export function convertSettings(oldSettings: ITokenColorizationRule[], resultRul if (!settings) { rule.settings = {}; } else { - for (let key in settings) { + for (const settingKey in settings) { + const key = settingKey; let mappings = settingToColorIdMapping[key]; if (mappings) { let colorHex = settings[key]; diff --git a/src/vs/workbench/services/themes/common/workbenchThemeService.ts b/src/vs/workbench/services/themes/common/workbenchThemeService.ts index 831b8ad3391f6..deb116b60f837 100644 --- a/src/vs/workbench/services/themes/common/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/common/workbenchThemeService.ts @@ -69,6 +69,7 @@ export interface IColorCustomizations { } export interface ITokenColorCustomizations { + [groupIdOrThemeSettingsId: string]: string | ITokenColorizationSetting | ITokenColorCustomizations | undefined | ITokenColorizationRule[]; comments?: string | ITokenColorizationSetting; strings?: string | ITokenColorizationSetting; numbers?: string | ITokenColorizationSetting; @@ -103,5 +104,6 @@ export interface IThemeExtensionPoint { label?: string; description?: string; path: string; + uiTheme?: typeof VS_LIGHT_THEME | typeof VS_DARK_THEME | typeof VS_HC_THEME; _watch: boolean; // unsupported options to watch location } \ No newline at end of file