Create the action only if the text change creation is successful. …

Make change for the infer type from usage could return undefined even if type is present if the type cannot be named
Fixes #22184
This commit is contained in:
Sheetal Nandi
2018-03-06 11:03:20 -08:00
parent 6f6c40186f
commit 70944428a1
2 changed files with 3 additions and 2 deletions

View File

@@ -186,7 +186,8 @@ namespace ts.codefix {
}
function makeFix(declaration: Declaration, start: number, type: Type | undefined, program: Program): Fix | undefined {
return type && { declaration, textChanges: [makeChange(declaration, start, type, program)] };
const change = makeChange(declaration, start, type, program);
return change && { declaration, textChanges: [change] };
}
function makeChange(declaration: Declaration, start: number, type: Type | undefined, program: Program): TextChange | undefined {

View File

@@ -13,4 +13,4 @@
////}
goTo.file("/b.ts");
verify.codeFixAvailable();
verify.not.codeFixAvailable();