Skip to content

Commit e29b2ec

Browse files
committed
Emit newline at end of file
1 parent 1981a0a commit e29b2ec

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

baselines/dom.generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17043,4 +17043,4 @@ type VRDisplayEventReason = "mounted" | "navigation" | "requested" | "unmounted"
1704317043
type VideoFacingModeEnum = "user" | "environment" | "left" | "right";
1704417044
type VisibilityState = "hidden" | "visible" | "prerender";
1704517045
type WorkerType = "classic" | "module";
17046-
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
17046+
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";

baselines/webworker.generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2727,4 +2727,4 @@ type ServiceWorkerState = "installing" | "installed" | "activating" | "activated
27272727
type ServiceWorkerUpdateViaCache = "imports" | "all" | "none";
27282728
type VisibilityState = "hidden" | "visible" | "prerender";
27292729
type WorkerType = "classic" | "module";
2730-
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
2730+
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";

src/emitter.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ function createTextWriter(newLine: string) {
8282
stack = [];
8383
}
8484

85-
function writeLine() {
86-
if (!lineStart) {
87-
output += newLine;
88-
lineStart = true;
89-
}
85+
function endLine() {
86+
output += newLine;
87+
lineStart = true;
9088
}
9189

9290
reset();
@@ -98,8 +96,9 @@ function createTextWriter(newLine: string) {
9896
increaseIndent() { indent++; },
9997
decreaseIndent() { indent--; },
10098

99+
endLine: endLine,
101100
print: write,
102-
printLine(c: string) { writeLine(); write(c); },
101+
printLine(c: string) { write(c); endLine(); },
103102

104103
clearStack() { stack = []; },
105104
stackIsEmpty() { return stack.length === 0; },
@@ -825,7 +824,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
825824
printer.printLineToStack(`interface ${processInterfaceType(i, i.name)} extends ${processedIName} {`);
826825
}
827826

828-
printer.printLine(`interface ${processInterfaceType(i, processedIName)}`);
827+
printer.print(`interface ${processInterfaceType(i, processedIName)}`);
829828

830829
const finalExtends = distinct([i.extends || "Object"].concat(i.implements || [])
831830
.filter(i => i !== "Object")
@@ -835,6 +834,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
835834
printer.print(` extends ${finalExtends.join(", ")}`);
836835
}
837836
printer.print(" {");
837+
printer.endLine();
838838
}
839839

840840
/// To decide if a given method is an indexer and should be emited
@@ -895,12 +895,13 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
895895
const ehParentCount = iNameToEhParents[i.name] && iNameToEhParents[i.name].length;
896896

897897
if (hasEventHandlers || ehParentCount > 1) {
898-
printer.printLine(`interface ${i.name}EventMap`);
898+
printer.print(`interface ${i.name}EventMap`);
899899
if (ehParentCount) {
900900
const extend = iNameToEhParents[i.name].map(i => i.name + "EventMap");
901901
printer.print(` extends ${extend.join(", ")}`);
902902
}
903903
printer.print(" {");
904+
printer.endLine();
904905
printer.increaseIndent();
905906
iNameToEhList[i.name]
906907
.sort(compareName)
@@ -1184,6 +1185,7 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
11841185
if (subtypes) {
11851186
const iteratorExtends = getIteratorExtends(i.iterator, subtypes);
11861187
const name = extendConflictsBaseTypes[i.name] ? `${i.name}Base` : i.name;
1188+
printer.printLine("");
11871189
printer.printLine(`interface ${name} ${iteratorExtends}{`);
11881190
printer.increaseIndent();
11891191
if (!iteratorExtends) {
@@ -1194,7 +1196,6 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
11941196
}
11951197
printer.decreaseIndent();
11961198
printer.printLine("}");
1197-
printer.printLine("");
11981199
}
11991200
}
12001201

@@ -1203,7 +1204,6 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
12031204
printer.printLine("/////////////////////////////");
12041205
printer.printLine("/// DOM Iterable APIs");
12051206
printer.printLine("/////////////////////////////");
1206-
printer.printLine("");
12071207

12081208
allInterfaces
12091209
.sort(compareName)

src/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const outputFolder = path.join(__SOURCE_DIRECTORY__, "../", "generated");
99
const tscPath = path.join(__SOURCE_DIRECTORY__, "../", "node_modules", "typescript", "lib", "tsc.js");
1010

1111
function normalizeLineEndings(text: string): string {
12-
return text.replace(/\r\n?/g, "\n").replace(/\n*$/, "\n");
12+
return text.replace(/\r\n?/g, "\n");
1313
}
1414

1515
function compareToBaselines() {

0 commit comments

Comments
 (0)