Skip to content

Commit cfbb15f

Browse files
authored
Ensure comments before // @filename are not part of the following virtual test file (microsoft#57579)
1 parent 63dd17b commit cfbb15f

File tree

239 files changed

+874
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+874
-1418
lines changed

src/harness/harnessIO.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,10 @@ export namespace TestCaseParser {
12321232
else {
12331233
// First metadata marker in the file
12341234
currentFileName = testMetaData[2].trim();
1235+
if (currentFileContent && ts.skipTrivia(currentFileContent, 0, /*stopAfterLineBreak*/ false, /*stopAtComments*/ false) !== currentFileContent.length) {
1236+
throw new Error("Non-comment test content appears before the first '// @Filename' directive");
1237+
}
1238+
currentFileContent = "";
12351239
}
12361240
}
12371241
else {

tests/baselines/reference/blockScopedNamespaceDifferentFile.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// [tests/cases/compiler/blockScopedNamespaceDifferentFile.ts] ////
22

33
//// [test.ts]
4-
// #15734 failed when test.ts comes before typings.d.ts
54
namespace C {
65
export class Name {
76
static funcData = A.AA.func();
@@ -21,7 +20,6 @@ declare namespace A {
2120

2221

2322
//// [out.js]
24-
// #15734 failed when test.ts comes before typings.d.ts
2523
var C;
2624
(function (C) {
2725
var Name = /** @class */ (function () {

tests/baselines/reference/blockScopedNamespaceDifferentFile.symbols

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
//// [tests/cases/compiler/blockScopedNamespaceDifferentFile.ts] ////
22

33
=== test.ts ===
4-
// #15734 failed when test.ts comes before typings.d.ts
54
namespace C {
65
>C : Symbol(C, Decl(test.ts, 0, 0))
76

87
export class Name {
9-
>Name : Symbol(Name, Decl(test.ts, 1, 13))
8+
>Name : Symbol(Name, Decl(test.ts, 0, 13))
109

1110
static funcData = A.AA.func();
12-
>funcData : Symbol(Name.funcData, Decl(test.ts, 2, 23))
11+
>funcData : Symbol(Name.funcData, Decl(test.ts, 1, 23))
1312
>A.AA.func : Symbol(A.AA.func, Decl(typings.d.ts, 1, 18))
1413
>A.AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
1514
>A : Symbol(A, Decl(typings.d.ts, 0, 0))
1615
>AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
1716
>func : Symbol(A.AA.func, Decl(typings.d.ts, 1, 18))
1817

1918
static someConst = A.AA.foo;
20-
>someConst : Symbol(Name.someConst, Decl(test.ts, 3, 38))
19+
>someConst : Symbol(Name.someConst, Decl(test.ts, 2, 38))
2120
>A.AA.foo : Symbol(A.AA.foo, Decl(typings.d.ts, 3, 13))
2221
>A.AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
2322
>A : Symbol(A, Decl(typings.d.ts, 0, 0))
2423
>AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21))
2524
>foo : Symbol(A.AA.foo, Decl(typings.d.ts, 3, 13))
2625

2726
constructor(parameters) {}
28-
>parameters : Symbol(parameters, Decl(test.ts, 6, 20))
27+
>parameters : Symbol(parameters, Decl(test.ts, 5, 20))
2928
}
3029
}
3130

tests/baselines/reference/blockScopedNamespaceDifferentFile.types

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// [tests/cases/compiler/blockScopedNamespaceDifferentFile.ts] ////
22

33
=== test.ts ===
4-
// #15734 failed when test.ts comes before typings.d.ts
54
namespace C {
65
>C : typeof C
76

tests/baselines/reference/commonJSReexport.symbols

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ hardline
1212
>hardline : Symbol(hardline, Decl(main.js, 0, 7))
1313

1414
=== first.js ===
15-
// #41422, based on prettier's exports
16-
1715
const hardline = { type: "hard" }
18-
>hardline : Symbol(hardline, Decl(first.js, 2, 5))
19-
>type : Symbol(type, Decl(first.js, 2, 18))
16+
>hardline : Symbol(hardline, Decl(first.js, 0, 5))
17+
>type : Symbol(type, Decl(first.js, 0, 18))
2018

2119
module.exports = {
2220
>module.exports : Symbol(module.exports, Decl(first.js, 0, 0))
23-
>module : Symbol(module, Decl(first.js, 2, 33))
21+
>module : Symbol(module, Decl(first.js, 0, 33))
2422
>exports : Symbol(module.exports, Decl(first.js, 0, 0))
2523

2624
hardline
27-
>hardline : Symbol(hardline, Decl(first.js, 3, 18))
25+
>hardline : Symbol(hardline, Decl(first.js, 1, 18))
2826
}
2927

3028

tests/baselines/reference/commonJSReexport.types

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ hardline
1313
>hardline : { type: string; }
1414

1515
=== first.js ===
16-
// #41422, based on prettier's exports
17-
1816
const hardline = { type: "hard" }
1917
>hardline : { type: string; }
2018
>{ type: "hard" } : { type: string; }

tests/baselines/reference/commonJsImportBindingElementNarrowType.symbols

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ if (a) {
1414
>a : Symbol(a, Decl(bar.js, 0, 7))
1515
}
1616
=== /foo.d.ts ===
17-
// Regresion test for GH#41957
18-
19-
2017
export const a: number | null;
21-
>a : Symbol(a, Decl(foo.d.ts, 3, 12))
18+
>a : Symbol(a, Decl(foo.d.ts, 0, 12))
2219

tests/baselines/reference/commonJsImportBindingElementNarrowType.types

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ if (a) {
1717
>1 : 1
1818
}
1919
=== /foo.d.ts ===
20-
// Regresion test for GH#41957
21-
22-
2320
export const a: number | null;
2421
>a : number | null
2522

tests/baselines/reference/commonSourceDirectory.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//// [tests/cases/compiler/commonSourceDirectory.ts] ////
22

33
//// [index.ts]
4-
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
5-
64
export const x = 0;
75

86
//// [bar.d.ts]

tests/baselines/reference/commonSourceDirectory.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/commonSourceDirectory.symbols

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ x + y;
1313
>y : Symbol(y, Decl(index.ts, 2, 8))
1414

1515
=== /node_modules/foo/index.ts ===
16-
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
17-
1816
export const x = 0;
19-
>x : Symbol(x, Decl(index.ts, 2, 12))
17+
>x : Symbol(x, Decl(index.ts, 0, 12))
2018

2119
=== /types/bar.d.ts ===
2220
declare module "bar" {

tests/baselines/reference/commonSourceDirectory.types

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ x + y;
1414
>y : 0
1515

1616
=== /node_modules/foo/index.ts ===
17-
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
18-
1917
export const x = 0;
2018
>x : 0
2119
>0 : 0

tests/baselines/reference/commonSourceDirectory_dts.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//// [tests/cases/compiler/commonSourceDirectory_dts.ts] ////
22

33
//// [bar.d.ts]
4-
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
5-
64
declare const y: number;
75

86
//// [index.ts]
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
//// [tests/cases/compiler/commonSourceDirectory_dts.ts] ////
22

33
=== /app/lib/bar.d.ts ===
4-
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
5-
64
declare const y: number;
7-
>y : Symbol(y, Decl(bar.d.ts, 2, 13))
5+
>y : Symbol(y, Decl(bar.d.ts, 0, 13))
86

97
=== /app/src/index.ts ===
108
/// <reference path="../lib/bar.d.ts" />
119
export const x = y;
1210
>x : Symbol(x, Decl(index.ts, 1, 12))
13-
>y : Symbol(y, Decl(bar.d.ts, 2, 13))
11+
>y : Symbol(y, Decl(bar.d.ts, 0, 13))
1412

tests/baselines/reference/commonSourceDirectory_dts.types

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//// [tests/cases/compiler/commonSourceDirectory_dts.ts] ////
22

33
=== /app/lib/bar.d.ts ===
4-
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
5-
64
declare const y: number;
75
>y : number
86

tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserv
33

44
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
55
==== /node_modules/dep/package.json (0 errors) ====
6-
// This documents bug https://github.com/microsoft/TypeScript/issues/50762.
7-
86
{
97
"name": "dep",
108
"version": "1.0.0",

tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolut
33

44
!!! error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.
55
==== /node_modules/dep/package.json (0 errors) ====
6-
// This documents bug https://github.com/microsoft/TypeScript/issues/50762.
7-
86
{
97
"name": "dep",
108
"version": "1.0.0",

tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResol
33

44
!!! error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'.
55
==== /node_modules/dep/package.json (0 errors) ====
6-
// This documents bug https://github.com/microsoft/TypeScript/issues/50762.
7-
86
{
97
"name": "dep",
108
"version": "1.0.0",

tests/baselines/reference/decoratorReferenceOnOtherProperty.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// [tests/cases/compiler/decoratorReferenceOnOtherProperty.ts] ////
22

33
//// [yoha.ts]
4-
// https://github.com/Microsoft/TypeScript/issues/19799
54
export class Yoha {}
65

76
//// [index.ts]
@@ -28,7 +27,6 @@ class Bar {
2827
"use strict";
2928
Object.defineProperty(exports, "__esModule", { value: true });
3029
exports.Yoha = void 0;
31-
// https://github.com/Microsoft/TypeScript/issues/19799
3230
var Yoha = /** @class */ (function () {
3331
function Yoha() {
3432
}

tests/baselines/reference/decoratorReferenceOnOtherProperty.symbols

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// [tests/cases/compiler/decoratorReferenceOnOtherProperty.ts] ////
22

33
=== yoha.ts ===
4-
// https://github.com/Microsoft/TypeScript/issues/19799
54
export class Yoha {}
65
>Yoha : Symbol(Yoha, Decl(yoha.ts, 0, 0))
76

tests/baselines/reference/decoratorReferenceOnOtherProperty.types

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// [tests/cases/compiler/decoratorReferenceOnOtherProperty.ts] ////
22

33
=== yoha.ts ===
4-
// https://github.com/Microsoft/TypeScript/issues/19799
54
export class Yoha {}
65
>Yoha : Yoha
76

tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//// [tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts] ////
22

3-
//// [file1.ts]
3+
//// [doNotEmitPinnedCommentOnNotEmittedNode.ts]
44
class C {
55
/*! remove pinned comment anywhere else */
66
public foo(x: string, y: any)
@@ -12,7 +12,7 @@ var x = 10;
1212
/*! remove pinned comment anywhere else */
1313
declare var OData: any;
1414

15-
//// [file1.js]
15+
//// [doNotEmitPinnedCommentOnNotEmittedNode.js]
1616
var C = (function () {
1717
function C() {
1818
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
//// [tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts] ////
22

3-
=== file1.ts ===
3+
=== doNotEmitPinnedCommentOnNotEmittedNode.ts ===
44
class C {
5-
>C : Symbol(C, Decl(file1.ts, 0, 0))
5+
>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 0))
66

77
/*! remove pinned comment anywhere else */
88
public foo(x: string, y: any)
9-
>foo : Symbol(C.foo, Decl(file1.ts, 0, 9), Decl(file1.ts, 2, 33))
10-
>x : Symbol(x, Decl(file1.ts, 2, 15))
11-
>y : Symbol(y, Decl(file1.ts, 2, 25))
9+
>foo : Symbol(C.foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 2, 33))
10+
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 2, 15))
11+
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 2, 25))
1212

1313
public foo(x: string, y: number) { }
14-
>foo : Symbol(C.foo, Decl(file1.ts, 0, 9), Decl(file1.ts, 2, 33))
15-
>x : Symbol(x, Decl(file1.ts, 3, 15))
16-
>y : Symbol(y, Decl(file1.ts, 3, 25))
14+
>foo : Symbol(C.foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 2, 33))
15+
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 15))
16+
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 25))
1717
}
1818

1919
var x = 10;
20-
>x : Symbol(x, Decl(file1.ts, 6, 3))
20+
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 6, 3))
2121

2222
/*! remove pinned comment anywhere else */
2323
declare var OData: any;
24-
>OData : Symbol(OData, Decl(file1.ts, 9, 11))
24+
>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 9, 11))
2525

tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//// [tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts] ////
22

3-
=== file1.ts ===
3+
=== doNotEmitPinnedCommentOnNotEmittedNode.ts ===
44
class C {
55
>C : C
66

tests/baselines/reference/duplicateIdentifierEnum.errors.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
duplicateIdentifierEnum_A.ts(2,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
2-
duplicateIdentifierEnum_A.ts(5,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
3-
duplicateIdentifierEnum_A.ts(9,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
4-
duplicateIdentifierEnum_A.ts(12,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
5-
duplicateIdentifierEnum_A.ts(16,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
6-
duplicateIdentifierEnum_A.ts(19,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
7-
duplicateIdentifierEnum_A.ts(23,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
8-
duplicateIdentifierEnum_A.ts(26,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
1+
duplicateIdentifierEnum_A.ts(1,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
2+
duplicateIdentifierEnum_A.ts(4,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
3+
duplicateIdentifierEnum_A.ts(8,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
4+
duplicateIdentifierEnum_A.ts(11,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
5+
duplicateIdentifierEnum_A.ts(15,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
6+
duplicateIdentifierEnum_A.ts(18,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
7+
duplicateIdentifierEnum_A.ts(22,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
8+
duplicateIdentifierEnum_A.ts(25,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
99
duplicateIdentifierEnum_B.ts(1,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
1010
duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
1111

1212

1313
==== duplicateIdentifierEnum_A.ts (8 errors) ====
14-
// Test the error message when attempting to merge an enum with a class, an interface, or a function.
1514
enum A {
1615
~
1716
!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations.
@@ -62,12 +61,12 @@ duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum declarations can only merg
6261
function D() {
6362
~
6463
!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations.
65-
!!! related TS6203 duplicateIdentifierEnum_A.ts:23:6: 'D' was also declared here.
64+
!!! related TS6203 duplicateIdentifierEnum_A.ts:22:6: 'D' was also declared here.
6665
return 0;
6766
}
6867
enum E {
6968
~
7069
!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations.
71-
!!! related TS6203 duplicateIdentifierEnum_A.ts:26:7: 'E' was also declared here.
70+
!!! related TS6203 duplicateIdentifierEnum_A.ts:25:7: 'E' was also declared here.
7271
bar
7372
}

tests/baselines/reference/duplicateIdentifierEnum.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// [tests/cases/compiler/duplicateIdentifierEnum.ts] ////
22

33
//// [duplicateIdentifierEnum_A.ts]
4-
// Test the error message when attempting to merge an enum with a class, an interface, or a function.
54
enum A {
65
bar
76
}
@@ -39,7 +38,6 @@ enum E {
3938
}
4039

4140
//// [duplicateIdentifierEnum_A.js]
42-
// Test the error message when attempting to merge an enum with a class, an interface, or a function.
4341
var A;
4442
(function (A) {
4543
A[A["bar"] = 0] = "bar";

0 commit comments

Comments
 (0)