Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable web type acquisition by default for js/ts #212370

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions extensions/typescript-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1280,22 +1280,21 @@
},
"typescript.tsserver.web.projectWideIntellisense.suppressSemanticErrors": {
"type": "boolean",
"default": true,
"default": false,
"description": "%configuration.tsserver.web.projectWideIntellisense.suppressSemanticErrors%",
"scope": "window"
},
"typescript.tsserver.web.typeAcquisition.enabled": {
"type": "boolean",
"default": true,
"description": "%configuration.tsserver.web.typeAcquisition.enabled%",
"scope": "window"
},
"typescript.tsserver.nodePath": {
"type": "string",
"description": "%configuration.tsserver.nodePath%",
"scope": "window"
},
"typescript.experimental.tsserver.web.typeAcquisition.enabled": {
"type": "boolean",
"default": false,
"description": "%configuration.experimental.tsserver.web.typeAcquisition.enabled%",
"scope": "window",
"tags": ["experimental"]
},
"typescript.preferGoToSourceDefinition": {
"type": "boolean",
"default": false,
Expand Down
4 changes: 2 additions & 2 deletions extensions/typescript-language-features/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@
"configuration.suggest.classMemberSnippets.enabled": "Enable/disable snippet completions for class members.",
"configuration.suggest.objectLiteralMethodSnippets.enabled": "Enable/disable snippet completions for methods in object literals.",
"configuration.tsserver.web.projectWideIntellisense.enabled": "Enable/disable project-wide IntelliSense on web. Requires that VS Code is running in a trusted context.",
"configuration.tsserver.web.projectWideIntellisense.suppressSemanticErrors": "Suppresses semantic errors. This is needed when using external packages as these can't be included analyzed on web.",
"configuration.tsserver.web.projectWideIntellisense.suppressSemanticErrors": "Suppresses semantic errors on web even when project wide IntelliSense is enabled. This is always on when project wide IntelliSense is not enabled or available. See `#typescript.tsserver.web.projectWideIntellisense.enabled#`",
"configuration.tsserver.web.typeAcquisition.enabled": "Enable/disable package acquisition on the web. This enables IntelliSense for imported packages. Requires `#typescript.tsserver.web.projectWideIntellisense.enabled#`.",
"configuration.tsserver.nodePath": "Run TS Server on a custom Node installation. This can be a path to a Node executable, or 'node' if you want VS Code to detect a Node installation.",
"configuration.experimental.tsserver.web.typeAcquisition.enabled": "Enable/disable package acquisition on the web.",
"walkthroughs.nodejsWelcome.title": "Get started with JavaScript and Node.js",
"walkthroughs.nodejsWelcome.description": "Make the most of Visual Studio Code's first-class JavaScript experience.",
"walkthroughs.nodejsWelcome.downloadNode.forMacOrWindows.title": "Install Node.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface TypeScriptServiceConfiguration {
readonly useSyntaxServer: SyntaxServerConfiguration;
readonly webProjectWideIntellisenseEnabled: boolean;
readonly webProjectWideIntellisenseSuppressSemanticErrors: boolean;
readonly webExperimentalTypeAcquisition: boolean;
readonly webTypeAcquisitionEnabled: boolean;
readonly enableDiagnosticsTelemetry: boolean;
readonly enableProjectDiagnostics: boolean;
readonly maxTsServerMemory: number;
Expand Down Expand Up @@ -150,7 +150,7 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
useSyntaxServer: this.readUseSyntaxServer(configuration),
webProjectWideIntellisenseEnabled: this.readWebProjectWideIntellisenseEnable(configuration),
webProjectWideIntellisenseSuppressSemanticErrors: this.readWebProjectWideIntellisenseSuppressSemanticErrors(configuration),
webExperimentalTypeAcquisition: this.readWebExperimentalTypeAcquisition(configuration),
webTypeAcquisitionEnabled: this.readWebTypeAcquisition(configuration),
enableDiagnosticsTelemetry: this.readEnableDiagnosticsTelemetry(configuration),
enableProjectDiagnostics: this.readEnableProjectDiagnostics(configuration),
maxTsServerMemory: this.readMaxTsServerMemory(configuration),
Expand Down Expand Up @@ -187,10 +187,6 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
return configuration.get<boolean>('typescript.disableAutomaticTypeAcquisition', false);
}

protected readWebExperimentalTypeAcquisition(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.experimental.tsserver.web.typeAcquisition.enabled', false);
}

protected readLocale(configuration: vscode.WorkspaceConfiguration): string | null {
const value = configuration.get<string>('typescript.locale', 'auto');
return !value || value === 'auto' ? null : value;
Expand Down Expand Up @@ -256,15 +252,19 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
return configuration.get<boolean>('typescript.tsserver.enableTracing', false);
}

private readWorkspaceSymbolsExcludeLibrarySymbols(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.workspaceSymbols.excludeLibrarySymbols', true);
}

private readWebProjectWideIntellisenseEnable(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.web.projectWideIntellisense.enabled', true);
}

private readWebProjectWideIntellisenseSuppressSemanticErrors(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.web.projectWideIntellisense.suppressSemanticErrors', true);
return configuration.get<boolean>('typescript.tsserver.web.projectWideIntellisense.suppressSemanticErrors', false);
}

private readWorkspaceSymbolsExcludeLibrarySymbols(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.workspaceSymbols.excludeLibrarySymbols', true);
private readWebTypeAcquisition(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.web.typeAcquisition.enabled', true);
}
}
20 changes: 13 additions & 7 deletions extensions/typescript-language-features/src/extension.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
new TypeScriptVersion(
TypeScriptVersionSource.Bundled,
vscode.Uri.joinPath(context.extensionUri, 'dist/browser/typescript/tsserver.web.js').toString(),
API.fromSimpleString('5.3.2')));
API.fromSimpleString('5.4.5')));

let experimentTelemetryReporter: IExperimentationTelemetryReporter | undefined;
const packageInfo = getPackageInfo(context);
Expand Down Expand Up @@ -118,15 +118,21 @@ async function startPreloadWorkspaceContentsIfNeeded(context: vscode.ExtensionCo
return;
}

const workspaceUri = vscode.workspace.workspaceFolders?.at(0)?.uri;
if (!workspaceUri || workspaceUri.scheme !== 'vscode-vfs' || !workspaceUri.authority.startsWith('github')) {
logger.info(`Skipped loading workspace contents for repository ${workspaceUri?.toString()}`);
if (!vscode.workspace.workspaceFolders) {
return;
}

const loader = new RemoteWorkspaceContentsPreloader(workspaceUri, logger);
context.subscriptions.push(loader);
return loader.triggerPreload();
await Promise.all(vscode.workspace.workspaceFolders.map(async folder => {
const workspaceUri = folder.uri;
if (workspaceUri.scheme !== 'vscode-vfs' || !workspaceUri.authority.startsWith('github')) {
logger.info(`Skipped pre loading workspace contents for repository ${workspaceUri?.toString()}`);
return;
}

const loader = new RemoteWorkspaceContentsPreloader(workspaceUri, logger);
context.subscriptions.push(loader);
await loader.triggerPreload();
}));
}

class RemoteWorkspaceContentsPreloader extends Disposable {
Expand Down
11 changes: 8 additions & 3 deletions extensions/typescript-language-features/src/languageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ClientCapability } from './typescriptService';
import TypeScriptServiceClient from './typescriptServiceClient';
import TypingsStatus from './ui/typingsStatus';
import { Disposable } from './utils/dispose';
import { isWeb } from './utils/platform';
import { isWeb, isWebAndHasSharedArrayBuffers } from './utils/platform';


const validateSetting = 'validate.enable';
Expand Down Expand Up @@ -141,8 +141,13 @@ export default class LanguageProvider extends Disposable {
return;
}

if (diagnosticsKind === DiagnosticKind.Semantic && isWeb() && this.client.configuration.webProjectWideIntellisenseSuppressSemanticErrors) {
return;
if (diagnosticsKind === DiagnosticKind.Semantic && isWeb()) {
if (!isWebAndHasSharedArrayBuffers()
|| this.client.configuration.webProjectWideIntellisenseSuppressSemanticErrors
|| !this.client.configuration.webProjectWideIntellisenseEnabled
) {
return;
}
}

const config = vscode.workspace.getConfiguration(this.id, file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class WorkerServerProcessFactory implements TsServerProcessFactory {
// Explicitly give TS Server its path so it can load local resources
'--executingFilePath', tsServerPath,
];
if (_configuration.webExperimentalTypeAcquisition) {
if (_configuration.webTypeAcquisitionEnabled) {
launchArgs.push('--experimentalTypeAcquisition');
}
return new WorkerServerProcess(kind, tsServerPath, this._extensionUri, launchArgs, tsServerLog, this._logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export class FileWatcherManager {
return FileWatcherManager.noopWatcher;
}

console.log('watching file:', path);

this.logger.logVerbose('fs.watchFile', { path });

let uri: URI;
Expand Down
Loading