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

This commit is contained in:
Jake Bailey
2022-10-12 16:03:07 -07:00
committed by GitHub
parent 6f7820c454
commit 07b87405e7
4 changed files with 17 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -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;
}
}
}

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode';
import * as objects from '../utils/objects';
import * as Proto from '../protocol';
export enum TsServerLogLevel {
Off,
@@ -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;
}
@@ -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 {

View File

@@ -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 {