Skip to content

Commit

Permalink
Create the action only if the text change creation is successful. …
Browse files Browse the repository at this point in the history
Make change for the infer type from usage could return undefined even if type is present if the type cannot be named
Fixes #22184
  • Loading branch information
sheetalkamat committed Mar 6, 2018
1 parent 6f6c401 commit 7094442
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/services/codefixes/inferFromUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
////}

goTo.file("/b.ts");
verify.codeFixAvailable();
verify.not.codeFixAvailable();

0 comments on commit 7094442

Please sign in to comment.