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

feat: support for "JavaScript and TypeScript Nightly" #1629

Merged
merged 2 commits into from Jul 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 13 additions & 30 deletions extensions/vscode-vue-language-features/src/features/tsVersion.ts
Expand Up @@ -22,8 +22,6 @@ export async function register(cmd: string, context: vscode.ExtensionContext, cl
const tsdk = getTsdk();
const defaultTsServer = shared.getWorkspaceTypescriptPath(defaultTsdk, (vscode.workspace.workspaceFolders ?? []).map(folder => folder.uri.fsPath));
const defaultTsVersion = defaultTsServer ? shared.getTypeScriptVersion(defaultTsServer) : undefined;
const latestTsPaths = getLatestTsPaths();
const latestTsVersion = latestTsPaths ? shared.getTypeScriptVersion(latestTsPaths.serverPath) : undefined;

const options: Record<string, vscode.QuickPickItem> = {};
options[0] = {
Expand All @@ -44,15 +42,8 @@ export async function register(cmd: string, context: vscode.ExtensionContext, cl
detail: defaultTsdk,
};
}
if (latestTsVersion) {
options[3] = {
label: 'Use Latest Version',
description: latestTsVersion,
detail: latestTsPaths!.serverPath
};
}
if (takeOverModeEnabled()) {
options[4] = {
options[3] = {
label: 'What is Takeover Mode?',
};
}
Expand All @@ -61,7 +52,7 @@ export async function register(cmd: string, context: vscode.ExtensionContext, cl
if (select === undefined)
return; // cancel

if (select === '4') {
if (select === '3') {
vscode.env.openExternal(vscode.Uri.parse('https://vuejs.org/guide/typescript/overview.html#takeover-mode'));
return;
}
Expand Down Expand Up @@ -158,6 +149,17 @@ function getWorkspaceTsPaths(useDefault = false) {
}

function getVscodeTsPaths() {
const nightly = vscode.extensions.getExtension('ms-vscode.vscode-typescript-next');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that user can only select nightly version when user install ms-vscode.vscode-typescript-next extension. They can't select the builtin typescript version.

Copy link
Member

Choose a reason for hiding this comment

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

It's for consistent with VSCode behavior, because seems VSCode cannot select it too.

if (nightly) {
const tsLibPath = path.join(nightly.extensionPath, 'node_modules/typescript/lib');
const serverPath = shared.findTypescriptModulePathInLib(tsLibPath);
if (serverPath) {
return {
serverPath,
localizedPath: shared.findTypescriptLocalizedPathInLib(tsLibPath, vscode.env.language)
};
}
}
return {
serverPath: shared.getVscodeTypescriptPath(vscode.env.appRoot),
localizedPath: shared.getVscodeTypescriptLocalizedPath(vscode.env.appRoot, vscode.env.language),
Expand All @@ -173,22 +175,3 @@ function getTsdk() {
function isUseWorkspaceTsdk(context: vscode.ExtensionContext) {
return context.workspaceState.get('typescript.useWorkspaceTsdk', false);
}

function getLatestTsPaths() {
try {
const extension = vscode.extensions.getExtension('ms-vscode.vscode-typescript-next');
if (extension) {
const tsLibPath = path.join(extension.extensionPath, 'node_modules/typescript/lib');
const serverPath = shared.findTypescriptModulePathInLib(tsLibPath);
if (serverPath) {
return {
serverPath,
localizedPath: shared.findTypescriptLocalizedPathInLib(tsLibPath, vscode.env.language)
};
}
}
} catch {
// noop
}
return undefined;
}