Skip to content

Commit

Permalink
Don't depend on typescript protocol.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Oct 11, 2022
1 parent 43957cc commit ec7dc98
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"description": "Dependencies shared by all extensions",
"dependencies": {
"typescript": "4.8.4"
"typescript": "npm:@typescript-deploys/[email protected]"
},
"scripts": {
"postinstall": "node ./postinstall.mjs"
Expand Down
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

0 comments on commit ec7dc98

Please sign in to comment.