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

Don't depend on typescript protocol.d.ts #163365

Merged
merged 1 commit into from
Oct 12, 2022
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 @@ -521,7 +521,7 @@ class MyCompletionItem extends vscode.CompletionItem {
}
}

function getScriptKindDetails(tsEntry: protocol.CompletionEntry,): string | undefined {
function getScriptKindDetails(tsEntry: Proto.CompletionEntry,): string | undefined {
if (!tsEntry.kindModifiers || tsEntry.kind !== PConst.Kind.script) {
return;
}
Expand Down
16 changes: 11 additions & 5 deletions extensions/typescript-language-features/src/protocol.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import * as Proto from 'typescript/lib/protocol';
export = Proto;
import * as ts from 'typescript/lib/tsserverlibrary';
export = ts.server.protocol;


declare enum ServerType {
Syntax = 'syntax',
Semantic = 'semantic',
}
declare module 'typescript/lib/protocol' {

interface Response {
readonly _serverType?: ServerType;
declare module 'typescript/lib/tsserverlibrary' {
namespace server.protocol {
type TextInsertion = ts.TextInsertion;
type ScriptElementKind = ts.ScriptElementKind;

interface Response {
readonly _serverType?: ServerType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import * as vscode from 'vscode';
import * as objects from '../utils/objects';
import * as Proto from '../protocol';

export enum TsServerLogLevel {
Off,
Expand Down Expand Up @@ -112,7 +113,7 @@ export interface TypeScriptServiceConfiguration {
readonly enableProjectDiagnostics: boolean;
readonly maxTsServerMemory: number;
readonly enablePromptUseWorkspaceTsdk: boolean;
readonly watchOptions: protocol.WatchOptions | undefined;
readonly watchOptions: Proto.WatchOptions | undefined;
readonly includePackageJsonAutoImports: 'auto' | 'on' | 'off' | undefined;
readonly enableTsServerTracing: boolean;
}
Expand Down Expand Up @@ -196,8 +197,8 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
return configuration.get<boolean>('typescript.tsserver.experimental.enableProjectDiagnostics', false);
}

protected readWatchOptions(configuration: vscode.WorkspaceConfiguration): protocol.WatchOptions | undefined {
return configuration.get<protocol.WatchOptions>('typescript.tsserver.watchOptions');
protected readWatchOptions(configuration: vscode.WorkspaceConfiguration): Proto.WatchOptions | undefined {
return configuration.get<Proto.WatchOptions>('typescript.tsserver.watchOptions');
}

protected readIncludePackageJsonAutoImports(configuration: vscode.WorkspaceConfiguration): 'auto' | 'on' | 'off' | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export async function openProjectConfigForFile(
return;
}

let res: ServerResponse.Response<protocol.ProjectInfoResponse> | undefined;
let res: ServerResponse.Response<Proto.ProjectInfoResponse> | undefined;
try {
res = await client.execute('projectInfo', { file, needFileNameList: false }, nulToken);
} catch {
Expand Down