Fix placement of indent for @ts-ignore comment (#24143)
This commit is contained in:
parent
339a56fbf0
commit
d4a3c9c61a
2 changed files with 21 additions and 1 deletions
|
@ -360,7 +360,8 @@ namespace ts.textChanges {
|
|||
// Otherwise, add an extra new line immediately before the error span.
|
||||
const insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition);
|
||||
const token = getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false);
|
||||
const text = `${insertAtLineStart ? "" : this.newLineCharacter}${sourceFile.text.slice(lineStartPosition, startPosition)}//${commentText}${this.newLineCharacter}`;
|
||||
const indent = sourceFile.text.slice(lineStartPosition, startPosition);
|
||||
const text = `${insertAtLineStart ? "" : this.newLineCharacter}//${commentText}${this.newLineCharacter}${indent}`;
|
||||
this.insertText(sourceFile, token.getStart(sourceFile), text);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @allowjs: true
|
||||
// @checkJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
////{
|
||||
//// a;
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: "Ignore this error message",
|
||||
index: 0,
|
||||
newFileContent:
|
||||
`{
|
||||
// @ts-ignore
|
||||
a;
|
||||
}`,
|
||||
});
|
Loading…
Reference in a new issue