parent
b0ea899d13
commit
3020f3d2e6
|
@ -21,6 +21,8 @@ namespace ts.codefix {
|
|||
}
|
||||
|
||||
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Identifier): void {
|
||||
changes.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token));
|
||||
// TODO (https://github.com/Microsoft/TypeScript/issues/21246): use shared helper
|
||||
suppressLeadingAndTrailingTrivia(token);
|
||||
changes.replaceRange(sourceFile, { pos: token.getStart(), end: token.end }, createPropertyAccess(createThis(), token));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C {
|
||||
//// foo: number;
|
||||
//// constructor() {[|
|
||||
//// /* a comment */foo = 10;
|
||||
//// |]}
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: "Add 'this.' to unresolved variable",
|
||||
newRangeContent: `
|
||||
/* a comment */this.foo = 10;
|
||||
`
|
||||
});
|
Loading…
Reference in a new issue