Switch remaining settings to use js/ts prefix

For #292934

Also renames some of the server settings to have a more consistent naming scheme. This is going to be annoying but is the best time to do this since we are already changing the full setting id
This commit is contained in:
Matt Bierner
2026-02-23 11:20:52 -08:00
parent 62028559c1
commit 11a5279976
17 changed files with 527 additions and 196 deletions

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { readUnifiedConfig, unifiedConfigSection } from '../utils/configuration';
import { Command } from './commandManager';
export const tsNativeExtensionId = 'typescriptteam.native-preview';
@@ -45,18 +46,19 @@ async function updateTsgoSetting(enable: boolean): Promise<void> {
}
}
const tsConfig = vscode.workspace.getConfiguration('typescript');
const currentValue = tsConfig.get<boolean>('experimental.useTsgo', false);
const currentValue = readUnifiedConfig<boolean>('experimental.useTsgo', false, { fallbackSection: 'typescript' });
if (currentValue === enable) {
return;
}
// Determine the target scope for the configuration update
let target = vscode.ConfigurationTarget.Global;
const inspect = tsConfig.inspect<boolean>('experimental.useTsgo');
if (inspect?.workspaceValue !== undefined) {
const unifiedConfig = vscode.workspace.getConfiguration(unifiedConfigSection);
const inspect = unifiedConfig.inspect<boolean>('experimental.useTsgo');
const legacyInspect = vscode.workspace.getConfiguration('typescript').inspect<boolean>('experimental.useTsgo');
if (inspect?.workspaceValue !== undefined || legacyInspect?.workspaceValue !== undefined) {
target = vscode.ConfigurationTarget.Workspace;
} else if (inspect?.workspaceFolderValue !== undefined) {
} else if (inspect?.workspaceFolderValue !== undefined || legacyInspect?.workspaceFolderValue !== undefined) {
target = vscode.ConfigurationTarget.WorkspaceFolder;
} else {
// If setting is not defined yet, use the same scope as typescript-go.executablePath
@@ -70,5 +72,5 @@ async function updateTsgoSetting(enable: boolean): Promise<void> {
}
}
await tsConfig.update('experimental.useTsgo', enable, target);
await unifiedConfig.update('experimental.useTsgo', enable, target);
}

View File

@@ -24,6 +24,10 @@ export class ElectronServiceConfigurationProvider extends BaseServiceConfigurati
}
protected readGlobalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
const unifiedInspect = configuration.inspect('js/ts.tsdk.path');
if (unifiedInspect && typeof unifiedInspect.globalValue === 'string') {
return this.fixPathPrefixes(unifiedInspect.globalValue);
}
const inspect = configuration.inspect('typescript.tsdk');
if (inspect && typeof inspect.globalValue === 'string') {
return this.fixPathPrefixes(inspect.globalValue);
@@ -32,6 +36,10 @@ export class ElectronServiceConfigurationProvider extends BaseServiceConfigurati
}
protected readLocalTsdk(configuration: vscode.WorkspaceConfiguration): string | null {
const unifiedInspect = configuration.inspect('js/ts.tsdk.path');
if (unifiedInspect && typeof unifiedInspect.workspaceValue === 'string') {
return this.fixPathPrefixes(unifiedInspect.workspaceValue);
}
const inspect = configuration.inspect('typescript.tsdk');
if (inspect && typeof inspect.workspaceValue === 'string') {
return this.fixPathPrefixes(inspect.workspaceValue);
@@ -44,7 +52,10 @@ export class ElectronServiceConfigurationProvider extends BaseServiceConfigurati
}
private readLocalNodePathWorker(configuration: vscode.WorkspaceConfiguration): string | null {
const inspect = configuration.inspect('typescript.tsserver.nodePath');
const unifiedInspect = configuration.inspect('js/ts.tsserver.node.path');
const inspect = (unifiedInspect?.workspaceValue && typeof unifiedInspect.workspaceValue === 'string')
? unifiedInspect
: configuration.inspect('typescript.tsserver.nodePath');
if (inspect?.workspaceValue && typeof inspect.workspaceValue === 'string') {
if (inspect.workspaceValue === 'node') {
return this.findNodePath();
@@ -64,7 +75,10 @@ export class ElectronServiceConfigurationProvider extends BaseServiceConfigurati
}
private readGlobalNodePathWorker(configuration: vscode.WorkspaceConfiguration): string | null {
const inspect = configuration.inspect('typescript.tsserver.nodePath');
const unifiedInspect = configuration.inspect('js/ts.tsserver.node.path');
const inspect = (unifiedInspect?.globalValue && typeof unifiedInspect.globalValue === 'string')
? unifiedInspect
: configuration.inspect('typescript.tsserver.nodePath');
if (inspect?.globalValue && typeof inspect.globalValue === 'string') {
if (inspect.globalValue === 'node') {
return this.findNodePath();

View File

@@ -153,29 +153,29 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
public loadFromWorkspace(): TypeScriptServiceConfiguration {
const configuration = vscode.workspace.getConfiguration();
return {
locale: this.readLocale(configuration),
locale: this.readLocale(),
globalTsdk: this.readGlobalTsdk(configuration),
localTsdk: this.readLocalTsdk(configuration),
npmLocation: this.readNpmLocation(configuration),
tsServerLogLevel: this.readTsServerLogLevel(configuration),
tsServerPluginPaths: this.readTsServerPluginPaths(configuration),
npmLocation: this.readNpmLocation(),
tsServerLogLevel: this.readTsServerLogLevel(),
tsServerPluginPaths: this.readTsServerPluginPaths(),
implicitProjectConfiguration: new ImplicitProjectConfiguration(configuration),
disableAutomaticTypeAcquisition: this.readDisableAutomaticTypeAcquisition(configuration),
useSyntaxServer: this.readUseSyntaxServer(configuration),
webProjectWideIntellisenseEnabled: this.readWebProjectWideIntellisenseEnable(configuration),
webProjectWideIntellisenseSuppressSemanticErrors: this.readWebProjectWideIntellisenseSuppressSemanticErrors(configuration),
webTypeAcquisitionEnabled: this.readWebTypeAcquisition(configuration),
enableDiagnosticsTelemetry: this.readEnableDiagnosticsTelemetry(configuration),
enableProjectDiagnostics: this.readEnableProjectDiagnostics(configuration),
maxTsServerMemory: this.readMaxTsServerMemory(configuration),
enablePromptUseWorkspaceTsdk: this.readEnablePromptUseWorkspaceTsdk(configuration),
webProjectWideIntellisenseEnabled: this.readWebProjectWideIntellisenseEnable(),
webProjectWideIntellisenseSuppressSemanticErrors: this.readWebProjectWideIntellisenseSuppressSemanticErrors(),
webTypeAcquisitionEnabled: this.readWebTypeAcquisition(),
enableDiagnosticsTelemetry: this.readEnableDiagnosticsTelemetry(),
enableProjectDiagnostics: this.readEnableProjectDiagnostics(),
maxTsServerMemory: this.readMaxTsServerMemory(),
enablePromptUseWorkspaceTsdk: this.readEnablePromptUseWorkspaceTsdk(),
useVsCodeWatcher: this.readUseVsCodeWatcher(configuration),
watchOptions: this.readWatchOptions(configuration),
includePackageJsonAutoImports: this.readIncludePackageJsonAutoImports(configuration),
enableTsServerTracing: this.readEnableTsServerTracing(configuration),
watchOptions: this.readWatchOptions(),
includePackageJsonAutoImports: this.readIncludePackageJsonAutoImports(),
enableTsServerTracing: this.readEnableTsServerTracing(),
localNodePath: this.readLocalNodePath(configuration),
globalNodePath: this.readGlobalNodePath(configuration),
workspaceSymbolsExcludeLibrarySymbols: this.readWorkspaceSymbolsExcludeLibrarySymbols(configuration),
workspaceSymbolsExcludeLibrarySymbols: this.readWorkspaceSymbolsExcludeLibrarySymbols(),
};
}
@@ -184,30 +184,35 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
protected abstract readLocalNodePath(configuration: vscode.WorkspaceConfiguration): string | null;
protected abstract readGlobalNodePath(configuration: vscode.WorkspaceConfiguration): string | null;
protected readTsServerLogLevel(configuration: vscode.WorkspaceConfiguration): TsServerLogLevel {
const setting = configuration.get<string>('typescript.tsserver.log', 'off');
protected readTsServerLogLevel(): TsServerLogLevel {
const setting = readUnifiedConfig<string>('tsserver.log', 'off', { fallbackSection: 'typescript' });
return TsServerLogLevel.fromString(setting);
}
protected readTsServerPluginPaths(configuration: vscode.WorkspaceConfiguration): string[] {
return configuration.get<string[]>('typescript.tsserver.pluginPaths', []);
protected readTsServerPluginPaths(): string[] {
return readUnifiedConfig<string[]>('tsserver.pluginPaths', [], { fallbackSection: 'typescript' });
}
protected readNpmLocation(configuration: vscode.WorkspaceConfiguration): string | null {
return configuration.get<string | null>('typescript.npm', null);
protected readNpmLocation(): string | null {
return readUnifiedConfig<string | null>('tsserver.npm.path', null, { fallbackSection: 'typescript', fallbackSubSectionNameOverride: 'npm' });
}
protected readDisableAutomaticTypeAcquisition(configuration: vscode.WorkspaceConfiguration): boolean {
const enabled = readUnifiedConfig<boolean | undefined>('tsserver.automaticTypeAcquisition.enabled', undefined, { fallbackSection: 'typescript' });
if (enabled !== undefined) {
return !enabled;
}
// Fall back to the old deprecated setting
return configuration.get<boolean>('typescript.disableAutomaticTypeAcquisition', false);
}
protected readLocale(configuration: vscode.WorkspaceConfiguration): string | null {
const value = configuration.get<string>('typescript.locale', 'auto');
protected readLocale(): string | null {
const value = readUnifiedConfig<string>('locale', 'auto', { fallbackSection: 'typescript' });
return !value || value === 'auto' ? null : value;
}
protected readUseSyntaxServer(configuration: vscode.WorkspaceConfiguration): SyntaxServerConfiguration {
const value = configuration.get<string>('typescript.tsserver.useSyntaxServer');
const value = readUnifiedConfig<string | undefined>('tsserver.useSyntaxServer', undefined, { fallbackSection: 'typescript' });
switch (value) {
case 'never': return SyntaxServerConfiguration.Never;
case 'always': return SyntaxServerConfiguration.Always;
@@ -225,13 +230,13 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
return SyntaxServerConfiguration.Never;
}
protected readEnableDiagnosticsTelemetry(configuration: vscode.WorkspaceConfiguration): boolean {
protected readEnableDiagnosticsTelemetry(): boolean {
// This setting does not appear in the settings view, as it is not to be enabled by users outside the team
return configuration.get<boolean>('typescript.enableDiagnosticsTelemetry', false);
return readUnifiedConfig<boolean>('enableDiagnosticsTelemetry', false, { fallbackSection: 'typescript' });
}
protected readEnableProjectDiagnostics(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.experimental.enableProjectDiagnostics', false);
protected readEnableProjectDiagnostics(): boolean {
return readUnifiedConfig<boolean>('tsserver.experimental.enableProjectDiagnostics', false, { fallbackSection: 'typescript' });
}
private readUseVsCodeWatcher(configuration: vscode.WorkspaceConfiguration): boolean {
@@ -256,12 +261,12 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
return experimentalConfig.workspaceFolderValue;
}
return configuration.get<Proto.WatchOptions | vscodeWatcherName>('typescript.tsserver.watchOptions', vscodeWatcherName) === vscodeWatcherName;
return readUnifiedConfig<Proto.WatchOptions | vscodeWatcherName>('tsserver.watchOptions', vscodeWatcherName, { fallbackSection: 'typescript' }) === vscodeWatcherName;
}
private readWatchOptions(configuration: vscode.WorkspaceConfiguration): Proto.WatchOptions | undefined {
const watchOptions = configuration.get<Proto.WatchOptions | vscodeWatcherName>('typescript.tsserver.watchOptions');
if (watchOptions === vscodeWatcherName) {
private readWatchOptions(): Proto.WatchOptions | undefined {
const watchOptions = readUnifiedConfig<Proto.WatchOptions | vscodeWatcherName | undefined>('tsserver.watchOptions', undefined, { fallbackSection: 'typescript' });
if (!watchOptions || watchOptions === vscodeWatcherName) {
return undefined;
}
@@ -269,41 +274,41 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
return { ...(watchOptions ?? {}) };
}
protected readIncludePackageJsonAutoImports(_configuration: vscode.WorkspaceConfiguration): 'auto' | 'on' | 'off' | undefined {
protected readIncludePackageJsonAutoImports(): 'auto' | 'on' | 'off' | undefined {
return readUnifiedConfig<'auto' | 'on' | 'off' | undefined>('preferences.includePackageJsonAutoImports', undefined, { fallbackSection: 'typescript' });
}
protected readMaxTsServerMemory(configuration: vscode.WorkspaceConfiguration): number {
protected readMaxTsServerMemory(): number {
const defaultMaxMemory = 3072;
const minimumMaxMemory = 128;
const memoryInMB = configuration.get<number>('typescript.tsserver.maxTsServerMemory', defaultMaxMemory);
const memoryInMB = readUnifiedConfig<number>('tsserver.maxMemory', defaultMaxMemory, { fallbackSection: 'typescript', fallbackSubSectionNameOverride: 'tsserver.maxTsServerMemory' });
if (!Number.isSafeInteger(memoryInMB)) {
return defaultMaxMemory;
}
return Math.max(memoryInMB, minimumMaxMemory);
}
protected readEnablePromptUseWorkspaceTsdk(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.enablePromptUseWorkspaceTsdk', false);
protected readEnablePromptUseWorkspaceTsdk(): boolean {
return readUnifiedConfig<boolean>('tsdk.promptToUseWorkspaceVersion', false, { fallbackSection: 'typescript', fallbackSubSectionNameOverride: 'enablePromptUseWorkspaceTsdk' });
}
protected readEnableTsServerTracing(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.enableTracing', false);
protected readEnableTsServerTracing(): boolean {
return readUnifiedConfig<boolean>('tsserver.tracing.enabled', false, { fallbackSection: 'typescript', fallbackSubSectionNameOverride: 'tsserver.enableTracing' });
}
private readWorkspaceSymbolsExcludeLibrarySymbols(_configuration: vscode.WorkspaceConfiguration): boolean {
private readWorkspaceSymbolsExcludeLibrarySymbols(): boolean {
return readUnifiedConfig<boolean>('workspaceSymbols.excludeLibrarySymbols', true, { scope: null, fallbackSection: 'typescript' });
}
private readWebProjectWideIntellisenseEnable(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.web.projectWideIntellisense.enabled', true);
private readWebProjectWideIntellisenseEnable(): boolean {
return readUnifiedConfig<boolean>('tsserver.web.projectWideIntellisense.enabled', true, { fallbackSection: 'typescript' });
}
private readWebProjectWideIntellisenseSuppressSemanticErrors(configuration: vscode.WorkspaceConfiguration): boolean {
return this.readWebTypeAcquisition(configuration) && configuration.get<boolean>('typescript.tsserver.web.projectWideIntellisense.suppressSemanticErrors', false);
private readWebProjectWideIntellisenseSuppressSemanticErrors(): boolean {
return this.readWebTypeAcquisition() && readUnifiedConfig<boolean>('tsserver.web.projectWideIntellisense.suppressSemanticErrors', false, { fallbackSection: 'typescript' });
}
private readWebTypeAcquisition(configuration: vscode.WorkspaceConfiguration): boolean {
return configuration.get<boolean>('typescript.tsserver.web.typeAcquisition.enabled', true);
private readWebTypeAcquisition(): boolean {
return readUnifiedConfig<boolean>('tsserver.web.typeAcquisition.enabled', true, { fallbackSection: 'typescript' });
}
}

View File

@@ -25,7 +25,7 @@ import { onCaseInsensitiveFileSystem } from './utils/fs.electron';
import { Lazy } from './utils/lazy';
import { getPackageInfo } from './utils/packageInfo';
import * as temp from './utils/temp.electron';
import { conditionalRegistration, requireGlobalConfiguration, requireHasVsCodeExtension } from './languageFeatures/util/dependentRegistration';
import { conditionalRegistration, requireGlobalConfiguration, requireGlobalUnifiedConfig, requireHasVsCodeExtension } from './languageFeatures/util/dependentRegistration';
import { DisposableStore } from './utils/dispose';
export function activate(
@@ -60,7 +60,7 @@ export function activate(
// Conditionally register features based on whether TSGO is enabled
context.subscriptions.push(conditionalRegistration([
requireGlobalConfiguration('typescript', 'experimental.useTsgo'),
requireGlobalUnifiedConfig('experimental.useTsgo', { fallbackSection: 'typescript' }),
requireHasVsCodeExtension(tsNativeExtensionId),
], () => {
// TSGO. Only register a small set of features that don't use TS Server

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { conditionalRegistration, requireGlobalConfiguration } from '../languageFeatures/util/dependentRegistration';
import { conditionalRegistration, requireGlobalUnifiedConfig } from '../languageFeatures/util/dependentRegistration';
import { supportsReadableByteStreams } from '../utils/platform';
import { AutoInstallerFs } from './autoInstallerFs';
import { MemFs } from './memFs';
@@ -16,7 +16,7 @@ export function registerAtaSupport(logger: Logger): vscode.Disposable {
}
return conditionalRegistration([
requireGlobalConfiguration('typescript', 'tsserver.web.typeAcquisition.enabled'),
requireGlobalUnifiedConfig('tsserver.web.typeAcquisition.enabled', { fallbackSection: 'typescript' }),
], () => {
return vscode.Disposable.from(
// Ata

View File

@@ -669,13 +669,12 @@ namespace CompletionConfiguration {
modeId: string,
scope: UnifiedConfigurationScope
): CompletionConfiguration {
const config = vscode.workspace.getConfiguration(modeId, scope);
return {
completeFunctionCalls: readUnifiedConfig<boolean>(CompletionConfiguration.completeFunctionCalls, false, { scope: scope, fallbackSection: modeId }),
pathSuggestions: readUnifiedConfig<boolean>(CompletionConfiguration.pathSuggestions, true, { scope: scope, fallbackSection: modeId }),
autoImportSuggestions: readUnifiedConfig<boolean>(CompletionConfiguration.autoImportSuggestions, true, { scope: scope, fallbackSection: modeId }),
nameSuggestions: readUnifiedConfig<boolean>(CompletionConfiguration.nameSuggestions, true, { scope: scope, fallbackSection: modeId }),
importStatementSuggestions: config.get<boolean>(CompletionConfiguration.importStatementSuggestions, true),
importStatementSuggestions: readUnifiedConfig<boolean>(CompletionConfiguration.importStatementSuggestions, true, { scope: scope, fallbackSection: modeId }),
};
}
}

View File

@@ -172,14 +172,11 @@ export default class FileConfigurationManager extends Disposable {
}
private getPreferences(document: vscode.TextDocument): Proto.UserPreferences {
const config = vscode.workspace.getConfiguration(
isTypeScriptDocument(document) ? 'typescript' : 'javascript',
document);
const fallbackSection = isTypeScriptDocument(document) ? 'typescript' : 'javascript';
const oldConfig = vscode.workspace.getConfiguration(fallbackSection, document);
const preferences: Proto.UserPreferences = {
...config.get('unstable'),
...oldConfig.get('unstable'),
quotePreference: getQuoteStylePreference(document, fallbackSection),
importModuleSpecifierPreference: getImportModuleSpecifierPreference(document, fallbackSection),
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(document, fallbackSection),

View File

@@ -12,7 +12,7 @@ import * as typeConverters from '../typeConverters';
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
import { Delayer } from '../utils/async';
import { nulToken } from '../utils/cancellation';
import { readUnifiedConfig } from '../utils/configuration';
import { readUnifiedConfig, unifiedConfigSection } from '../utils/configuration';
import { Disposable } from '../utils/dispose';
import FileConfigurationManager from './fileConfigurationManager';
import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration';
@@ -174,7 +174,7 @@ class UpdateImportsOnFileRenameHandler extends Disposable {
return false;
}
case alwaysItem: {
const config = vscode.workspace.getConfiguration('js/ts');
const config = vscode.workspace.getConfiguration(unifiedConfigSection);
config.update(
updateImportsOnFileMoveName,
UpdateImportsOnFileMoveSetting.Always,
@@ -182,7 +182,7 @@ class UpdateImportsOnFileRenameHandler extends Disposable {
return true;
}
case neverItem: {
const config = vscode.workspace.getConfiguration('js/ts');
const config = vscode.workspace.getConfiguration(unifiedConfigSection);
config.update(
updateImportsOnFileMoveName,
UpdateImportsOnFileMoveSetting.Never,

View File

@@ -90,19 +90,6 @@ export function requireMinVersion(
);
}
export function requireGlobalConfiguration(
section: string,
configValue: string,
) {
return new Condition(
() => {
const config = vscode.workspace.getConfiguration(section, null);
return !!config.get<boolean>(configValue);
},
vscode.workspace.onDidChangeConfiguration
);
}
/**
* Requires that a configuration value has been modified from its default value in either the global or workspace scope
*

View File

@@ -162,23 +162,7 @@ export default class LanguageProvider extends Disposable {
return;
}
const config = vscode.workspace.getConfiguration(this.id, file);
const reportUnnecessary = config.get<boolean>('showUnused', true);
const reportDeprecated = config.get<boolean>('showDeprecated', true);
this.client.diagnosticsManager.updateDiagnostics(file, this._diagnosticLanguage, diagnosticsKind, diagnostics.filter(diag => {
// Don't bother reporting diagnostics we know will not be rendered
if (!reportUnnecessary) {
if (diag.reportUnnecessary && diag.severity === vscode.DiagnosticSeverity.Hint) {
return false;
}
}
if (!reportDeprecated) {
if (diag.reportDeprecated && diag.severity === vscode.DiagnosticSeverity.Hint) {
return false;
}
}
return true;
}), ranges);
this.client.diagnosticsManager.updateDiagnostics(file, this._diagnosticLanguage, diagnosticsKind, diagnostics, ranges);
}
public configFileDiagnosticsReceived(file: vscode.Uri, diagnostics: vscode.Diagnostic[]): void {

View File

@@ -5,35 +5,33 @@
import * as vscode from 'vscode';
import { TsServerLogLevel } from '../configuration/configuration';
import { UnifiedConfigValue, unifiedConfigSection } from '../utils/configuration';
import { Disposable } from '../utils/dispose';
export class LogLevelMonitor extends Disposable {
private static readonly logLevelConfigKey = 'typescript.tsserver.log';
private static readonly logLevelChangedStorageKey = 'typescript.tsserver.logLevelChanged';
private static readonly doNotPromptLogLevelStorageKey = 'typescript.tsserver.doNotPromptLogLevel';
private readonly _logLevel: UnifiedConfigValue<string>;
constructor(private readonly context: vscode.ExtensionContext) {
super();
this._register(vscode.workspace.onDidChangeConfiguration(this.onConfigurationChange, this, this._disposables));
this._logLevel = this._register(new UnifiedConfigValue<string>('tsserver.log', 'off', { fallbackSection: 'typescript' }));
this._register(this._logLevel.onDidChange(() => {
this.context.globalState.update(LogLevelMonitor.logLevelChangedStorageKey, new Date());
}));
if (this.shouldNotifyExtendedLogging()) {
this.notifyExtendedLogging();
}
}
private onConfigurationChange(event: vscode.ConfigurationChangeEvent) {
const logLevelChanged = event.affectsConfiguration(LogLevelMonitor.logLevelConfigKey);
if (!logLevelChanged) {
return;
}
this.context.globalState.update(LogLevelMonitor.logLevelChangedStorageKey, new Date());
}
private get logLevel(): TsServerLogLevel {
return TsServerLogLevel.fromString(vscode.workspace.getConfiguration().get<string>(LogLevelMonitor.logLevelConfigKey, 'off'));
return TsServerLogLevel.fromString(this._logLevel.getValue());
}
/**
@@ -90,7 +88,7 @@ export class LogLevelMonitor extends Disposable {
return;
}
if (selection.choice === Choice.DisableLogging) {
return vscode.workspace.getConfiguration().update(LogLevelMonitor.logLevelConfigKey, 'off', true);
return vscode.workspace.getConfiguration().update(`${unifiedConfigSection}.tsserver.log`, 'off', true);
} else if (selection.choice === Choice.DoNotShowAgain) {
return this.context.globalState.update(LogLevelMonitor.doNotPromptLogLevelStorageKey, true);
}

View File

@@ -9,6 +9,7 @@ import * as vscode from 'vscode';
import { wait } from '../test/testUtils';
import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService';
import { coalesce } from '../utils/arrays';
import { readUnifiedConfig } from '../utils/configuration';
import { Disposable } from '../utils/dispose';
import { exists } from '../utils/fs';
import { isTsConfigFileName } from '../configuration/languageDescription';
@@ -289,7 +290,7 @@ class TscTaskProvider extends Disposable implements vscode.TaskProvider {
}
private onConfigurationChanged(): void {
const type = vscode.workspace.getConfiguration('typescript.tsc').get<AutoDetect>('autoDetect');
const type = readUnifiedConfig<AutoDetect | undefined>('tsc.autoDetect', undefined, { fallbackSection: 'typescript' });
this.autoDetect = typeof type === 'undefined' ? AutoDetect.on : type;
}
}

View File

@@ -6,6 +6,7 @@
import * as vscode from 'vscode';
import { TypeScriptServiceConfiguration } from '../configuration/configuration';
import { tsNativeExtensionId } from '../commands/useTsgo';
import { readUnifiedConfig, unifiedConfigSection } from '../utils/configuration';
import { setImmediate } from '../utils/async';
import { Disposable } from '../utils/dispose';
import { ITypeScriptVersionProvider, TypeScriptVersion } from './versionProvider';
@@ -131,8 +132,7 @@ export class TypeScriptVersionManager extends Disposable {
const trusted = await vscode.workspace.requestWorkspaceTrust();
if (trusted) {
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
const tsConfig = vscode.workspace.getConfiguration('typescript');
await tsConfig.update('tsdk', version.pathLabel, false);
await vscode.workspace.getConfiguration(unifiedConfigSection).update('tsdk.path', version.pathLabel, false);
this.updateActiveVersion(version);
}
},
@@ -146,8 +146,7 @@ export class TypeScriptVersionManager extends Disposable {
return undefined;
}
const tsConfig = vscode.workspace.getConfiguration('typescript');
const isUsingTsgo = tsConfig.get<boolean>('experimental.useTsgo', false);
const isUsingTsgo = readUnifiedConfig<boolean>('experimental.useTsgo', false, { fallbackSection: 'typescript' });
return {
label: (isUsingTsgo ? '• ' : '') + vscode.l10n.t("Use TypeScript Native Preview (Experimental)"),

View File

@@ -536,13 +536,13 @@ export default class TypeScriptServiceClient extends Disposable implements IType
public async openTsServerLogFile(): Promise<boolean> {
if (this._configuration.tsServerLogLevel === TsServerLogLevel.Off) {
vscode.window.showErrorMessage<vscode.MessageItem>(
vscode.l10n.t("TS Server logging is off. Please set 'typescript.tsserver.log' and restart the TS server to enable logging"),
vscode.l10n.t("TS Server logging is off. Please set 'js/ts.tsserver.log' and restart the TS server to enable logging"),
{
title: vscode.l10n.t("Enable logging and restart TS server"),
})
.then(selection => {
if (selection) {
return vscode.workspace.getConfiguration().update('typescript.tsserver.log', 'verbose', true).then(() => {
return vscode.workspace.getConfiguration().update('js/ts.tsserver.log', 'verbose', true).then(() => {
this.restartTsServer();
});
}

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode';
import { ITypeScriptServiceClient } from '../typescriptService';
import { readUnifiedConfig } from '../utils/configuration';
import { Disposable } from '../utils/dispose';
@@ -95,21 +96,19 @@ export class AtaProgressReporter extends Disposable {
}
private async onTypesInstallerInitializationFailed() {
const config = vscode.workspace.getConfiguration('typescript');
if (config.get<boolean>('check.npmIsInstalled', true)) {
if (readUnifiedConfig<boolean>('tsserver.checkNpmIsInstalled', true, { fallbackSection: 'typescript', fallbackSubSectionNameOverride: 'check.npmIsInstalled' })) {
const dontShowAgain: vscode.MessageItem = {
title: vscode.l10n.t("Don't Show Again"),
};
const selected = await vscode.window.showWarningMessage(
vscode.l10n.t(
"Could not install typings files for JavaScript language features. Please ensure that NPM is installed, or configure 'typescript.npm' in your user settings. Alternatively, check the [documentation]({0}) to learn more.",
"Could not install typings files for JavaScript language features. Please ensure that NPM is installed, or configure 'js/ts.tsserver.npm.path' in your user settings. Alternatively, check the [documentation]({0}) to learn more.",
'https://go.microsoft.com/fwlink/?linkid=847635'
),
dontShowAgain);
if (selected === dontShowAgain) {
config.update('check.npmIsInstalled', false, true);
vscode.workspace.getConfiguration('js/ts').update('tsserver.checkNpmIsInstalled', false, true);
}
}
}