Merge pull request #22343 from Microsoft/codeFixActionNotUndefined
Create the action only if the text change creation is successful.
This commit is contained in:
commit
36b45e3f13
3 changed files with 22 additions and 1 deletions
|
@ -2923,6 +2923,10 @@ Actual: ${stringify(fullActual)}`);
|
|||
if (!codeFixes.length) {
|
||||
this.raiseError(`verifyCodeFixAvailable failed - expected code fixes but none found.`);
|
||||
}
|
||||
codeFixes.forEach(fix => fix.changes.forEach(change => {
|
||||
assert.isObject(change, `Invalid change in code fix: ${JSON.stringify(fix)}`);
|
||||
change.textChanges.forEach(textChange => assert.isObject(textChange, `Invalid textChange in codeFix: ${JSON.stringify(fix)}`));
|
||||
}));
|
||||
if (info) {
|
||||
assert.equal(info.length, codeFixes.length);
|
||||
ts.zipWith(codeFixes, info, (fix, info) => {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noImplicitAny: true
|
||||
|
||||
// @Filename: /a.ts
|
||||
////export class D {}
|
||||
////export default new D();
|
||||
|
||||
// @Filename: /b.ts
|
||||
////export class C {
|
||||
//// [|set x(val) {}|]
|
||||
//// method() { this.x = import("./a"); }
|
||||
////}
|
||||
|
||||
goTo.file("/b.ts");
|
||||
verify.not.codeFixAvailable();
|
Loading…
Reference in a new issue