diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 47d47461ae..839107555c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1925,6 +1925,8 @@ module ts { function emitSourceFile(node: SourceFile) { currentSourceFile = node; + // Start new file on new line + writeLine(); emitDetachedComments(node); // emit prologue directives prior to __extends var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js new file mode 100644 index 0000000000..a96ecb45f6 --- /dev/null +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/sourceMapWithMultipleFilesWithCopyright.ts] //// + +//// [a.ts] +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ + +var x = { + a: 10, + b: 20 +}; + +//// [b.ts] +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ + +/// +var y = x; + +//// [a.js] +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ +var x = { + a: 10, + b: 20 +}; +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ +/// +var y = x; +//# sourceMappingURL=a.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map new file mode 100644 index 0000000000..59e28d92f9 --- /dev/null +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.js.map @@ -0,0 +1,2 @@ +//// [a.js.map] +{"version":3,"file":"a.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AAAA;;6EAE6E;AAE7E,IAAI,CAAC,GAAG;IACJ,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;CACR,CAAC;ACPF;;6EAE6E;AAG7E,AADA,2BAA2B;IACvB,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt new file mode 100644 index 0000000000..5a87f6c04e --- /dev/null +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.sourcemap.txt @@ -0,0 +1,134 @@ +=================================================================== +JsFile: a.js +mapUrl: a.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:a.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>/*-------------------------------------------------------------------------- +1 > +2 >^^^^^^^^^^-> +1 > +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +--- +>>>Copyright +>>>---------------------------------------------------------------------------*/ +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->/*-------------------------------------------------------------------------- + >Copyright + >---------------------------------------------------------------------------*/ +1->Emitted(3, 78) Source(3, 78) + SourceIndex(0) +--- +>>>var x = { +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^^^-> +1 > + > + > +2 >var +3 > x +4 > = +1 >Emitted(4, 1) Source(5, 1) + SourceIndex(0) +2 >Emitted(4, 5) Source(5, 5) + SourceIndex(0) +3 >Emitted(4, 6) Source(5, 6) + SourceIndex(0) +4 >Emitted(4, 9) Source(5, 9) + SourceIndex(0) +--- +>>> a: 10, +1->^^^^ +2 > ^ +3 > ^^ +4 > ^^ +5 > ^-> +1->{ + > +2 > a +3 > : +4 > 10 +1->Emitted(5, 5) Source(6, 5) + SourceIndex(0) +2 >Emitted(5, 6) Source(6, 6) + SourceIndex(0) +3 >Emitted(5, 8) Source(6, 8) + SourceIndex(0) +4 >Emitted(5, 10) Source(6, 10) + SourceIndex(0) +--- +>>> b: 20 +1->^^^^ +2 > ^ +3 > ^^ +4 > ^^ +1->, + > +2 > b +3 > : +4 > 20 +1->Emitted(6, 5) Source(7, 5) + SourceIndex(0) +2 >Emitted(6, 6) Source(7, 6) + SourceIndex(0) +3 >Emitted(6, 8) Source(7, 8) + SourceIndex(0) +4 >Emitted(6, 10) Source(7, 10) + SourceIndex(0) +--- +>>>}; +1 >^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >} +2 > ; +1 >Emitted(7, 2) Source(8, 2) + SourceIndex(0) +2 >Emitted(7, 3) Source(8, 3) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:a.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>/*-------------------------------------------------------------------------- +1-> +2 >^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(1, 1) + SourceIndex(1) +--- +>>>Copyright +>>>---------------------------------------------------------------------------*/ +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1->/*-------------------------------------------------------------------------- + >Copyright + >---------------------------------------------------------------------------*/ +1->Emitted(10, 78) Source(3, 78) + SourceIndex(1) +--- +>>>/// +1 > +2 > +3 >^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > + >/// + > +2 > +3 >/// +1 >Emitted(11, 1) Source(6, 1) + SourceIndex(1) +2 >Emitted(11, 1) Source(5, 1) + SourceIndex(1) +3 >Emitted(11, 28) Source(5, 28) + SourceIndex(1) +--- +>>>var y = x; +1 >^^^^ +2 > ^ +3 > ^^^ +4 > ^ +5 > ^ +6 > ^^^^^^^^^^^^^^^^^^-> +1 > + >var +2 > y +3 > = +4 > x +5 > ; +1 >Emitted(12, 5) Source(6, 5) + SourceIndex(1) +2 >Emitted(12, 6) Source(6, 6) + SourceIndex(1) +3 >Emitted(12, 9) Source(6, 9) + SourceIndex(1) +4 >Emitted(12, 10) Source(6, 10) + SourceIndex(1) +5 >Emitted(12, 11) Source(6, 11) + SourceIndex(1) +--- +>>>//# sourceMappingURL=a.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types new file mode 100644 index 0000000000..8e53a8914f --- /dev/null +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/b.ts === +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ + +/// +var y = x; +>y : { a: number; b: number; } +>x : { a: number; b: number; } + +=== tests/cases/compiler/a.ts === +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ + +var x = { +>x : { a: number; b: number; } +>{ + a: 10, + b: 20 +} : { a: number; b: number; } + + a: 10, +>a : number + + b: 20 +>b : number + +}; + diff --git a/tests/cases/compiler/sourceMapWithMultipleFilesWithCopyright.ts b/tests/cases/compiler/sourceMapWithMultipleFilesWithCopyright.ts new file mode 100644 index 0000000000..58730c7d6d --- /dev/null +++ b/tests/cases/compiler/sourceMapWithMultipleFilesWithCopyright.ts @@ -0,0 +1,19 @@ +// @out: a.js +// @sourcemap: true +// @Filename: a.ts +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ + +var x = { + a: 10, + b: 20 +}; + +// @Filename: b.ts +/*-------------------------------------------------------------------------- +Copyright +---------------------------------------------------------------------------*/ + +/// +var y = x; \ No newline at end of file