Skip to content

Commit 680af0f

Browse files
author
Arthur Ozga
committed
use getStart()
1 parent 4af0e2a commit 680af0f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ namespace ts.codefix {
2121
return undefined;
2222
}
2323

24-
const textChanges: TextChange[] = [{ newText: " implements", span: { start: extendsToken.pos, length: extendsToken.end - extendsToken.pos } }];
24+
let changeStart = extendsToken.getStart(sourceFile);
25+
let changeEnd = extendsToken.getEnd();
26+
const textChanges: TextChange[] = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }];
2527

2628
// We replace existing keywords with commas.
2729
for (let i = 1; i < heritageClauses.length; i++) {
2830
const keywordToken = heritageClauses[i].getFirstToken();
2931
if (keywordToken) {
30-
textChanges.push({ newText: ",", span: { start: keywordToken.pos, length: keywordToken.end - keywordToken.pos } });
32+
changeStart = keywordToken.getStart(sourceFile);
33+
changeEnd = keywordToken.getEnd();
34+
textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } });
3135
}
3236
}
3337

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference path='fourslash.ts' />
22

33
//// interface I {}
4-
//// [|class C extends I|]{}
4+
//// [|/* */ class /* */ C /* */ extends /* */ I|]{}
55

6-
verify.rangeAfterCodeFix("class C implements I");
6+
verify.rangeAfterCodeFix("/* */ class /* */ C /* */ implements /* */ I");

0 commit comments

Comments
 (0)