Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { readUnifiedConfig, unifiedConfigSection } from '../utils/configuration'
import { Command } from './commandManager';

export const tsNativeExtensionOldId = 'typescriptteam.native-preview';
export const tsNativeExtensionIds = ['typescriptteam.vscode-typescript', tsNativeExtensionOldId] as const;
export const tsNativeExtensionIds = [
'typescriptteam.vscode-typescript',
'typescriptteam.vscode-typescript-nightly',
Comment thread
DanielRosenwasser marked this conversation as resolved.
tsNativeExtensionOldId
] as const;

export function getTsNativeExtension(): vscode.Extension<unknown> | undefined {
for (const extensionId of tsNativeExtensionIds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as tas from 'vscode-tas-client';
import { IExperimentationTelemetryReporter } from './experimentTelemetryReporter';

interface ExperimentTypes {
suggestNativePreview: boolean;
suggestTS7IfNoPlugins: boolean;
}

export class ExperimentationService {
Expand Down
2 changes: 1 addition & 1 deletion extensions/typescript-language-features/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function activate(
context.subscriptions.push(experimentTelemetryReporter);

const experimentationService = new ExperimentationService(experimentTelemetryReporter, id, version, context.globalState);
suggestNativePreview(context, experimentationService);
suggestNativePreview(context, experimentationService, pluginManager);
}

// Register features that work in both TSGO and non-TSGO modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class TypeScriptVersionManager extends Disposable {
const isUsingTsgo = readUnifiedConfig<boolean>('experimental.useTsgo', false, { fallbackSection: 'typescript' });

return {
label: (isUsingTsgo ? '• ' : '') + vscode.l10n.t("Use TypeScript Native Preview (Experimental)"),
label: (isUsingTsgo ? '• ' : '') + vscode.l10n.t("Use TypeScript 7"),
description: nativePreviewExtension.packageJSON.version,
run: async () => {
await vscode.commands.executeCommand('typescript.native-preview.enable');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const emptyAuthority = 'ts-nul-authority';

export const inMemoryResourcePrefix = '^';

const copilotChatExtensionId = 'github.copilot-chat';
export const copilotChatExtensionId = 'github.copilot-chat';

interface WatchEvent {
updated?: Set<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,40 @@
import * as vscode from 'vscode';
import { getTsNativeExtension, tsNativeExtensionOldId } from '../commands/useTsgo';
import { ExperimentationService } from '../experimentationService';
import type { PluginManager } from '../tsServer/plugins.js';
import { copilotChatExtensionId } from '../typescriptServiceClient.js';
import { hasModifiedUnifiedConfig } from '../utils/configuration';

const suggestNativePreviewStorageKey = 'typescript.suggestNativePreview.dismissed';
const suggestTS7NoPluginsStorageKey = 'typescript.suggestTS7NoPlugins.dismissed';

export async function suggestNativePreview(
context: vscode.ExtensionContext,
experimentationService: ExperimentationService,
pluginManager: PluginManager
): Promise<void> {
if (context.globalState.get<boolean>(suggestNativePreviewStorageKey)) {
return;
if (context.globalState.get<boolean>(suggestTS7NoPluginsStorageKey)) {
// return;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO

}

// Only show when the window is active
if (!vscode.window.state.active) {
return;
}

// Only show when the nightly extension is installed
if (!vscode.extensions.getExtension('ms-vscode.vscode-typescript-next')) {
// Don't show if the TypeScript 7 extension is already installed,
// or if we have any settings indicating it was installed previously.
if (getTsNativeExtension() || hasModifiedUnifiedConfig('experimental.useTsgo', { fallbackSection: 'typescript' })) {
// Also don't prompt in the future.
await context.globalState.update(suggestTS7NoPluginsStorageKey, true);
return;
}

// Don't show if the native preview extension is already installed
if (getTsNativeExtension()) {
// Also don't prompt in the future
await context.globalState.update(suggestNativePreviewStorageKey, true);
// TSServer plugins are not supported by TypeScript 7
if (pluginManager.plugins.some(plugin => plugin.extension.id.toLowerCase() !== copilotChatExtensionId)) {
return;
}

const inExperiment = await experimentationService.getTreatmentVariable('suggestNativePreview', false);
const inExperiment = await experimentationService.getTreatmentVariable('suggestTS7IfNoPlugins', false);
if (!inExperiment) {
return;
}
Expand All @@ -44,18 +49,18 @@ export async function suggestNativePreview(
const dismiss: vscode.MessageItem = { title: vscode.l10n.t("Don't Show Again") };

const selection = await vscode.window.showInformationMessage(
vscode.l10n.t("Try TypeScript 7 Native Preview for significantly faster type checking and language features."),
vscode.l10n.t("Try TypeScript 7 for significantly faster type checking and language features."),
{},
install,
learnMore,
dismiss,
);
// Don't show again
await context.globalState.update(suggestNativePreviewStorageKey, true);
await context.globalState.update(suggestTS7NoPluginsStorageKey, true);

if (selection === install) {
await vscode.commands.executeCommand('workbench.extensions.installExtension', tsNativeExtensionOldId);
} else if (selection === learnMore) {
await vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/vscode-try-ts-7-learn-more'));
await vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/typescript7'));
}
}