Skip to content

Commit

Permalink
Properly gate type acquisition on web (microsoft#223403)
Browse files Browse the repository at this point in the history
For microsoft#221299

Make sure we don't register the file system at all in these cases
  • Loading branch information
mjbvz authored Jul 23, 2024
1 parent d4bb523 commit ea0d703
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
16 changes: 3 additions & 13 deletions extensions/typescript-language-features/src/extension.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { registerBaseCommands } from './commands/index';
import { TypeScriptServiceConfiguration } from './configuration/configuration';
import { BrowserServiceConfigurationProvider } from './configuration/configuration.browser';
import { ExperimentationTelemetryReporter, IExperimentationTelemetryReporter } from './experimentTelemetryReporter';
import { AutoInstallerFs } from './filesystems/autoInstallerFs';
import { MemFs } from './filesystems/memFs';
import { registerAtaSupport } from './filesystems/ata';
import { createLazyClientHost, lazilyActivateClient } from './lazyClientHost';
import { Logger } from './logging/logger';
import RemoteRepositories from './remoteRepositories.browser';
Expand All @@ -25,7 +24,7 @@ import { ITypeScriptVersionProvider, TypeScriptVersion, TypeScriptVersionSource
import { ActiveJsTsEditorTracker } from './ui/activeJsTsEditorTracker';
import { Disposable } from './utils/dispose';
import { getPackageInfo } from './utils/packageInfo';
import { isWebAndHasSharedArrayBuffers, supportsReadableByteStreams } from './utils/platform';
import { isWebAndHasSharedArrayBuffers } from './utils/platform';

class StaticVersionProvider implements ITypeScriptVersionProvider {

Expand Down Expand Up @@ -102,16 +101,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
await startPreloadWorkspaceContentsIfNeeded(context, logger);
}));

if (supportsReadableByteStreams()) {
context.subscriptions.push(vscode.workspace.registerFileSystemProvider('vscode-global-typings', new MemFs(), {
isCaseSensitive: true,
isReadonly: false
}));
context.subscriptions.push(vscode.workspace.registerFileSystemProvider('vscode-node-modules', new AutoInstallerFs(), {
isCaseSensitive: true,
isReadonly: false
}));
}
context.subscriptions.push(registerAtaSupport());

return getExtensionApi(onCompletionAccepted.event, pluginManager);
}
Expand Down
30 changes: 30 additions & 0 deletions extensions/typescript-language-features/src/filesystems/ata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { conditionalRegistration, requireGlobalConfiguration } from '../languageFeatures/util/dependentRegistration';
import { supportsReadableByteStreams } from '../utils/platform';
import { AutoInstallerFs } from './autoInstallerFs';
import { MemFs } from './memFs';

export function registerAtaSupport(): vscode.Disposable {
if (!supportsReadableByteStreams()) {
return vscode.Disposable.from();
}

return conditionalRegistration([
requireGlobalConfiguration('typescript', 'tsserver.web.typeAcquisition.enabled'),
], () => {
return vscode.Disposable.from(
vscode.workspace.registerFileSystemProvider('vscode-global-typings', new MemFs(), {
isCaseSensitive: true,
isReadonly: false
}),
vscode.workspace.registerFileSystemProvider('vscode-node-modules', new AutoInstallerFs(), {
isCaseSensitive: true,
isReadonly: false
}));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class WorkerServerProcessFactory implements TsServerProcessFactory {
version: TypeScriptVersion,
args: readonly string[],
kind: TsServerProcessKind,
_configuration: TypeScriptServiceConfiguration,
configuration: TypeScriptServiceConfiguration,
_versionManager: TypeScriptVersionManager,
_nodeVersionManager: NodeVersionManager,
tsServerLog: TsServerLog | undefined,
Expand All @@ -50,10 +50,10 @@ export class WorkerServerProcessFactory implements TsServerProcessFactory {
...args,
// Explicitly give TS Server its path so it can load local resources
'--executingFilePath', tsServerPath,
// Enable/disable web type acquisition
(configuration.webTypeAcquisitionEnabled && supportsReadableByteStreams() ? '--experimentalTypeAcquisition' : '--disableAutomaticTypingAcquisition'),
];
if (_configuration.webTypeAcquisitionEnabled && supportsReadableByteStreams()) {
launchArgs.push('--experimentalTypeAcquisition');
}

return new WorkerServerProcess(kind, tsServerPath, this._extensionUri, launchArgs, tsServerLog, this._logger);
}
}
Expand Down

0 comments on commit ea0d703

Please sign in to comment.