errorCodes in CodeFixRequestArgs is non-optional (#25815)

This commit is contained in:
Andy
2018-07-20 11:10:33 -07:00
committed by GitHub
parent 31d599abaf
commit b21c1fd595
3 changed files with 3 additions and 6 deletions

View File

@@ -705,7 +705,7 @@ namespace ts.server.protocol {
/**
* Errorcodes we want to get the fixes for.
*/
errorCodes?: ReadonlyArray<number>;
errorCodes: ReadonlyArray<number>;
}
export interface GetCombinedCodeFixRequestArgs {

View File

@@ -1767,15 +1767,12 @@ namespace ts.server {
}
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CodeFixAction> | ReadonlyArray<CodeFixAction> | undefined {
if (args.errorCodes!.length === 0) { // TODO: GH#18217
return undefined;
}
const { file, project } = this.getFileAndProject(args);
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
const { startPosition, endPosition } = this.getStartAndEndPosition(args, scriptInfo);
const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes!, this.getFormatOptions(file), this.getPreferences(file));
const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file));
return simplifiedResult ? codeActions.map(codeAction => this.mapCodeFixAction(codeAction)) : codeActions;
}