Skip to content

Commit 173b5df

Browse files
committed
Refactor sourcemap emitter
1 parent 1f8aa05 commit 173b5df

28 files changed

+723
-431
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3016,7 +3016,7 @@ namespace ts {
30163016
const sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName);
30173017
const printer = createPrinter({ removeComments: true, omitTrailingSemicolon: true });
30183018
const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
3019-
printer.writeNode(EmitHint.Unspecified, sig!, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217
3019+
printer.writeNode(EmitHint.Unspecified, sig!, /*sourceFile*/ sourceFile, getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217
30203020
return writer;
30213021
}
30223022
}

src/compiler/comments.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ namespace ts {
155155
writer.writeLine();
156156
}
157157
else {
158-
writer.write(" ");
158+
writer.writeSpace(" ");
159159
}
160160
}
161161

162162
function emitTrailingSynthesizedComment(comment: SynthesizedComment) {
163163
if (!writer.isAtStartOfLine()) {
164-
writer.write(" ");
164+
writer.writeSpace(" ");
165165
}
166166
writeSynthesizedComment(comment);
167167
if (comment.hasTrailingNewLine) {
@@ -283,7 +283,7 @@ namespace ts {
283283
writer.writeLine();
284284
}
285285
else if (kind === SyntaxKind.MultiLineCommentTrivia) {
286-
writer.write(" ");
286+
writer.writeSpace(" ");
287287
}
288288
}
289289

@@ -303,7 +303,7 @@ namespace ts {
303303
if (!shouldWriteComment(currentText, commentPos)) return;
304304
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
305305
if (!writer.isAtStartOfLine()) {
306-
writer.write(" ");
306+
writer.writeSpace(" ");
307307
}
308308

309309
if (emitPos) emitPos(commentPos);
@@ -342,7 +342,7 @@ namespace ts {
342342
writer.writeLine();
343343
}
344344
else {
345-
writer.write(" ");
345+
writer.writeSpace(" ");
346346
}
347347
}
348348

0 commit comments

Comments
 (0)