From 38518f236e71a3159ee4aad64147967f0b19159e Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 5 Dec 2023 09:18:57 +0100 Subject: [PATCH] debt - typecheck our top level JS files (#166844) (#200007) * debt - typecheck our top level JS files (#166844) * fix build --- src/bootstrap-fork.js | 7 ++++++- src/bootstrap-window.js | 9 +++++++++ src/main.js | 2 ++ src/tsconfig.json | 6 ++++++ src/tsec.exemptions.json | 1 + src/vs/base/common/product.ts | 3 +++ src/vs/platform/environment/common/argv.ts | 1 + src/vs/platform/environment/node/argv.ts | 1 + src/vs/platform/environment/test/node/argv.test.ts | 8 ++++---- 9 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/bootstrap-fork.js b/src/bootstrap-fork.js index 036522f23ce..9de1e6f0d15 100644 --- a/src/bootstrap-fork.js +++ b/src/bootstrap-fork.js @@ -56,6 +56,9 @@ function pipeLoggingToParent() { * @param {ArrayLike} args */ function safeToArray(args) { + /** + * @type {string[]} + */ const seen = []; const argsArray = []; @@ -178,7 +181,7 @@ function pipeLoggingToParent() { Object.defineProperty(stream, 'write', { set: () => { }, - get: () => (chunk, encoding, callback) => { + get: () => (/** @type {string | Buffer | Uint8Array} */ chunk, /** @type {BufferEncoding | undefined} */ encoding, /** @type {((err?: Error | undefined) => void) | undefined} */ callback) => { buf += chunk.toString(encoding); const eol = buf.length > MAX_STREAM_BUFFER_LENGTH ? buf.length : buf.lastIndexOf('\n'); if (eol !== -1) { @@ -239,7 +242,9 @@ function configureCrashReporter() { const crashReporterProcessType = process.env['VSCODE_CRASH_REPORTER_PROCESS_TYPE']; if (crashReporterProcessType) { try { + // @ts-ignore if (process['crashReporter'] && typeof process['crashReporter'].addExtraParameter === 'function' /* Electron only */) { + // @ts-ignore process['crashReporter'].addExtraParameter('processType', crashReporterProcessType); } } catch (error) { diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index 6334d62afc5..85409cc5a21 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -20,6 +20,7 @@ // Browser else { + // @ts-ignore globalThis.MonacoBootstrapWindow = factory(); } }(this, function () { @@ -71,12 +72,16 @@ }; const isDev = !!safeProcess.env['VSCODE_DEV']; const enableDeveloperKeybindings = isDev || forceEnableDeveloperKeybindings; + /** + * @type {() => void | undefined} + */ let developerDeveloperKeybindingsDisposable; if (enableDeveloperKeybindings) { developerDeveloperKeybindingsDisposable = registerDeveloperKeybindings(disallowReloadKeybinding); } // Get the nls configuration into the process.env as early as possible + // @ts-ignore const nlsConfig = globalThis.MonacoBootstrap.setupNLS(); let locale = nlsConfig.availableLanguages['*'] || 'en'; @@ -90,6 +95,10 @@ window['MonacoEnvironment'] = {}; + /** + * @typedef {any} LoaderConfig + */ + /** @type {LoaderConfig} */ const loaderConfig = { baseUrl: `${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out`, 'vs/nls': nlsConfig, diff --git a/src/main.js b/src/main.js index 7087474bcee..a632301fe9d 100644 --- a/src/main.js +++ b/src/main.js @@ -513,6 +513,7 @@ function registerListeners() { * @type {string[]} */ const macOpenFiles = []; + // @ts-ignore global['macOpenFiles'] = macOpenFiles; app.on('open-file', function (event, path) { macOpenFiles.push(path); @@ -539,6 +540,7 @@ function registerListeners() { app.on('open-url', onOpenUrl); }); + // @ts-ignore global['getOpenUrls'] = function () { app.removeListener('open-url', onOpenUrl); diff --git a/src/tsconfig.json b/src/tsconfig.json index 56ca209276b..1e0c8b14a1a 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -25,7 +25,13 @@ "include": [ "./bootstrap.js", "./bootstrap-amd.js", + "./bootstrap-fork.js", + "./bootstrap-node.js", + "./bootstrap-window.js", + "./cli.js", + "./main.js", "./server-main.js", + "./server-cli.js", "./typings", "./vs/**/*.ts", "vscode-dts/vscode.proposed.*.d.ts", diff --git a/src/tsec.exemptions.json b/src/tsec.exemptions.json index eb8405c96cb..5fef171569e 100644 --- a/src/tsec.exemptions.json +++ b/src/tsec.exemptions.json @@ -14,6 +14,7 @@ "vs/workbench/services/keybinding/test/node/keyboardMapperTestUtils.ts" ], "ban-trustedtypes-createpolicy": [ + "bootstrap-window.js", "vs/amdX.ts", "vs/base/browser/trustedTypes.ts", "vs/base/worker/workerMain.ts", diff --git a/src/vs/base/common/product.ts b/src/vs/base/common/product.ts index 61a1623d76d..3cdab02a17b 100644 --- a/src/vs/base/common/product.ts +++ b/src/vs/base/common/product.ts @@ -226,8 +226,11 @@ export type IFileContentCondition = (IFileLanguageCondition | IFilePathCondition export interface IAppCenterConfiguration { readonly 'win32-x64': string; + readonly 'win32-arm64': string; readonly 'linux-x64': string; readonly 'darwin': string; + readonly 'darwin-universal': string; + readonly 'darwin-arm64': string; } export interface IConfigBasedExtensionTip { diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts index f205cc30439..54bd029eddc 100644 --- a/src/vs/platform/environment/common/argv.ts +++ b/src/vs/platform/environment/common/argv.ts @@ -115,6 +115,7 @@ export interface NativeParsedArgs { 'profile'?: string; 'profile-temp'?: boolean; 'disable-chromium-sandbox'?: boolean; + sandbox?: boolean; 'enable-coi'?: boolean; diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 79046c7fa20..1457aa1ed29 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -121,6 +121,7 @@ export const OPTIONS: OptionDescriptions> = { 'inspect-brk-extensions': { type: 'string', allowEmptyValue: true, deprecates: ['debugBrkPluginHost'], args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") }, 'disable-gpu': { type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") }, 'disable-chromium-sandbox': { type: 'boolean', cat: 't', description: localize('disableChromiumSandbox', "Use this option only when there is requirement to launch the application as sudo user on Linux or when running as an elevated user in an applocker environment on Windows.") }, + 'sandbox': { type: 'boolean' }, 'ms-enable-electron-run-as-node': { type: 'boolean', global: true }, 'telemetry': { type: 'boolean', cat: 't', description: localize('telemetry', "Shows all telemetry events which VS code collects.") }, diff --git a/src/vs/platform/environment/test/node/argv.test.ts b/src/vs/platform/environment/test/node/argv.test.ts index b0d9a5661f4..20f1e237aa4 100644 --- a/src/vs/platform/environment/test/node/argv.test.ts +++ b/src/vs/platform/environment/test/node/argv.test.ts @@ -112,13 +112,13 @@ suite('parseArgs', () => { _: string[]; } - const options1: OptionDescriptions = { + const options1 = { 'testcmd': c('A test command', { testArg: o('A test command option'), _: { type: 'string[]' } }), _: { type: 'string[]' } - }; + } satisfies OptionDescriptions; assertParse( options1, ['testcmd', '--testArg=foo'], @@ -142,13 +142,13 @@ suite('parseArgs', () => { _: string[]; } - const options2: OptionDescriptions = { + const options2 = { 'testcmd': c('A test command', { testArg: o('A test command option') }), testX: { type: 'boolean', global: true, description: '' }, _: { type: 'string[]' } - }; + } satisfies OptionDescriptions; assertParse( options2, ['testcmd', '--testArg=foo', '--testX'],