Skip to content

Commit ea0d703

Browse files
authored
Properly gate type acquisition on web (microsoft#223403)
For microsoft#221299 Make sure we don't register the file system at all in these cases
1 parent d4bb523 commit ea0d703

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

extensions/typescript-language-features/src/extension.browser.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import { registerBaseCommands } from './commands/index';
1111
import { TypeScriptServiceConfiguration } from './configuration/configuration';
1212
import { BrowserServiceConfigurationProvider } from './configuration/configuration.browser';
1313
import { ExperimentationTelemetryReporter, IExperimentationTelemetryReporter } from './experimentTelemetryReporter';
14-
import { AutoInstallerFs } from './filesystems/autoInstallerFs';
15-
import { MemFs } from './filesystems/memFs';
14+
import { registerAtaSupport } from './filesystems/ata';
1615
import { createLazyClientHost, lazilyActivateClient } from './lazyClientHost';
1716
import { Logger } from './logging/logger';
1817
import RemoteRepositories from './remoteRepositories.browser';
@@ -25,7 +24,7 @@ import { ITypeScriptVersionProvider, TypeScriptVersion, TypeScriptVersionSource
2524
import { ActiveJsTsEditorTracker } from './ui/activeJsTsEditorTracker';
2625
import { Disposable } from './utils/dispose';
2726
import { getPackageInfo } from './utils/packageInfo';
28-
import { isWebAndHasSharedArrayBuffers, supportsReadableByteStreams } from './utils/platform';
27+
import { isWebAndHasSharedArrayBuffers } from './utils/platform';
2928

3029
class StaticVersionProvider implements ITypeScriptVersionProvider {
3130

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

105-
if (supportsReadableByteStreams()) {
106-
context.subscriptions.push(vscode.workspace.registerFileSystemProvider('vscode-global-typings', new MemFs(), {
107-
isCaseSensitive: true,
108-
isReadonly: false
109-
}));
110-
context.subscriptions.push(vscode.workspace.registerFileSystemProvider('vscode-node-modules', new AutoInstallerFs(), {
111-
isCaseSensitive: true,
112-
isReadonly: false
113-
}));
114-
}
104+
context.subscriptions.push(registerAtaSupport());
115105

116106
return getExtensionApi(onCompletionAccepted.event, pluginManager);
117107
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as vscode from 'vscode';
7+
import { conditionalRegistration, requireGlobalConfiguration } from '../languageFeatures/util/dependentRegistration';
8+
import { supportsReadableByteStreams } from '../utils/platform';
9+
import { AutoInstallerFs } from './autoInstallerFs';
10+
import { MemFs } from './memFs';
11+
12+
export function registerAtaSupport(): vscode.Disposable {
13+
if (!supportsReadableByteStreams()) {
14+
return vscode.Disposable.from();
15+
}
16+
17+
return conditionalRegistration([
18+
requireGlobalConfiguration('typescript', 'tsserver.web.typeAcquisition.enabled'),
19+
], () => {
20+
return vscode.Disposable.from(
21+
vscode.workspace.registerFileSystemProvider('vscode-global-typings', new MemFs(), {
22+
isCaseSensitive: true,
23+
isReadonly: false
24+
}),
25+
vscode.workspace.registerFileSystemProvider('vscode-node-modules', new AutoInstallerFs(), {
26+
isCaseSensitive: true,
27+
isReadonly: false
28+
}));
29+
});
30+
}

extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class WorkerServerProcessFactory implements TsServerProcessFactory {
4040
version: TypeScriptVersion,
4141
args: readonly string[],
4242
kind: TsServerProcessKind,
43-
_configuration: TypeScriptServiceConfiguration,
43+
configuration: TypeScriptServiceConfiguration,
4444
_versionManager: TypeScriptVersionManager,
4545
_nodeVersionManager: NodeVersionManager,
4646
tsServerLog: TsServerLog | undefined,
@@ -50,10 +50,10 @@ export class WorkerServerProcessFactory implements TsServerProcessFactory {
5050
...args,
5151
// Explicitly give TS Server its path so it can load local resources
5252
'--executingFilePath', tsServerPath,
53+
// Enable/disable web type acquisition
54+
(configuration.webTypeAcquisitionEnabled && supportsReadableByteStreams() ? '--experimentalTypeAcquisition' : '--disableAutomaticTypingAcquisition'),
5355
];
54-
if (_configuration.webTypeAcquisitionEnabled && supportsReadableByteStreams()) {
55-
launchArgs.push('--experimentalTypeAcquisition');
56-
}
56+
5757
return new WorkerServerProcess(kind, tsServerPath, this._extensionUri, launchArgs, tsServerLog, this._logger);
5858
}
5959
}

0 commit comments

Comments
 (0)