Update a few interfaces for TS 2.6.2

This commit is contained in:
Matt Bierner 2017-11-20 15:53:05 -08:00
parent 2bbdabd97e
commit 3200d2afa6
3 changed files with 10 additions and 12 deletions

View file

@ -84,7 +84,7 @@ export function getJavascriptMode(documentRegions: LanguageModelCache<HTMLDocume
doComplete(document: TextDocument, position: Position): CompletionList { doComplete(document: TextDocument, position: Position): CompletionList {
updateCurrentTextDocument(document); updateCurrentTextDocument(document);
let offset = currentTextDocument.offsetAt(position); let offset = currentTextDocument.offsetAt(position);
let completions = jsLanguageService.getCompletionsAtPosition(FILE_NAME, offset); let completions = jsLanguageService.getCompletionsAtPosition(FILE_NAME, offset, { includeExternalModuleExports: false });
if (!completions) { if (!completions) {
return { isIncomplete: false, items: [] }; return { isIncomplete: false, items: [] };
} }

View file

@ -134,13 +134,13 @@ class ApplyCompletionCodeActionCommand implements Command {
private readonly client: ITypeScriptServiceClient private readonly client: ITypeScriptServiceClient
) { } ) { }
public async execute(file: string, codeActions: CodeAction[]): Promise<boolean> { public async execute(_file: string, codeActions: CodeAction[]): Promise<boolean> {
if (codeActions.length === 0) { if (codeActions.length === 0) {
return true; return true;
} }
if (codeActions.length === 1) { if (codeActions.length === 1) {
return applyCodeAction(this.client, codeActions[0], file); return applyCodeAction(this.client, codeActions[0]);
} }
interface MyQuickPickItem extends QuickPickItem { interface MyQuickPickItem extends QuickPickItem {
@ -165,7 +165,7 @@ class ApplyCompletionCodeActionCommand implements Command {
if (!action) { if (!action) {
return false; return false;
} }
return applyCodeAction(this.client, action, file); return applyCodeAction(this.client, action);
} }
} }
@ -250,10 +250,10 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
} }
try { try {
const args = { const args: CompletionsRequestArgs = {
...vsPositionToTsFileLocation(file, position), ...vsPositionToTsFileLocation(file, position),
includeExternalModuleExports: config.autoImportSuggestions includeExternalModuleExports: config.autoImportSuggestions
} as CompletionsRequestArgs; };
const msg = await this.client.execute('completions', args, token); const msg = await this.client.execute('completions', args, token);
// This info has to come from the tsserver. See https://github.com/Microsoft/TypeScript/issues/2831 // This info has to come from the tsserver. See https://github.com/Microsoft/TypeScript/issues/2831
// let isMemberCompletion = false; // let isMemberCompletion = false;

View file

@ -29,8 +29,7 @@ export function getEditForCodeAction(
export async function applyCodeAction( export async function applyCodeAction(
client: ITypeScriptServiceClient, client: ITypeScriptServiceClient,
action: Proto.CodeAction, action: Proto.CodeAction
file: string
): Promise<boolean> { ): Promise<boolean> {
const workspaceEdit = getEditForCodeAction(client, action); const workspaceEdit = getEditForCodeAction(client, action);
if (workspaceEdit) { if (workspaceEdit) {
@ -38,17 +37,16 @@ export async function applyCodeAction(
return false; return false;
} }
} }
return applyCodeActionCommands(client, action, file); return applyCodeActionCommands(client, action);
} }
export async function applyCodeActionCommands( export async function applyCodeActionCommands(
client: ITypeScriptServiceClient, client: ITypeScriptServiceClient,
action: Proto.CodeAction, action: Proto.CodeAction
file: string
): Promise<boolean> { ): Promise<boolean> {
if (action.commands && action.commands.length) { if (action.commands && action.commands.length) {
for (const command of action.commands) { for (const command of action.commands) {
const response = await client.execute('applyCodeActionCommand', { file, command }); const response = await client.execute('applyCodeActionCommand', { command });
if (!response || !response.body) { if (!response || !response.body) {
return false; return false;
} }