Skip to content

Commit 1415cf4

Browse files
author
Kanchalai Tanglertsampan
committed
Update tests and baselines to declare class declaration before use
1 parent d511884 commit 1415cf4

File tree

223 files changed

+1624
-1557
lines changed

Some content is hidden

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

223 files changed

+1624
-1557
lines changed

tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2495: Type 'StringIterator' is not an array type or a string type.
2-
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6): error TS2304: Cannot find name 'Symbol'.
1+
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(10,6): error TS2304: Cannot find name 'Symbol'.
2+
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(15,15): error TS2495: Type 'StringIterator' is not an array type or a string type.
33

44

55
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts (2 errors) ====
6-
for (var v of new StringIterator) { }
7-
~~~~~~~~~~~~~~~~~~
8-
!!! error TS2495: Type 'StringIterator' is not an array type or a string type.
96

107
// In ES3/5, you cannot for...of over an arbitrary iterable.
118
class StringIterator {
@@ -20,4 +17,8 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6
2017
!!! error TS2304: Cannot find name 'Symbol'.
2118
return this;
2219
}
23-
}
20+
}
21+
22+
for (var v of new StringIterator) { }
23+
~~~~~~~~~~~~~~~~~~
24+
!!! error TS2495: Type 'StringIterator' is not an array type or a string type.

tests/baselines/reference/ES5For-ofTypeCheck10.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//// [ES5For-ofTypeCheck10.ts]
2-
for (var v of new StringIterator) { }
32

43
// In ES3/5, you cannot for...of over an arbitrary iterable.
54
class StringIterator {
@@ -12,12 +11,11 @@ class StringIterator {
1211
[Symbol.iterator]() {
1312
return this;
1413
}
15-
}
14+
}
15+
16+
for (var v of new StringIterator) { }
1617

1718
//// [ES5For-ofTypeCheck10.js]
18-
for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) {
19-
var v = _a[_i];
20-
}
2119
// In ES3/5, you cannot for...of over an arbitrary iterable.
2220
var StringIterator = (function () {
2321
function StringIterator() {
@@ -33,3 +31,6 @@ var StringIterator = (function () {
3331
};
3432
return StringIterator;
3533
}());
34+
for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) {
35+
var v = _a[_i];
36+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//// [classDoesNotDependOnBaseTypes.ts]
2-
var x: StringTree;
3-
if (typeof x !== "string") {
4-
x[0] = "";
5-
x[0] = new StringTreeCollection;
6-
}
7-
82
type StringTree = string | StringTreeCollection;
93
class StringTreeCollectionBase {
104
[n: number]: StringTree;
115
}
126

13-
class StringTreeCollection extends StringTreeCollectionBase { }
7+
class StringTreeCollection extends StringTreeCollectionBase { }
8+
9+
var x: StringTree;
10+
if (typeof x !== "string") {
11+
x[0] = "";
12+
x[0] = new StringTreeCollection;
13+
}
1414

1515
//// [classDoesNotDependOnBaseTypes.js]
1616
var __extends = (this && this.__extends) || (function () {
@@ -23,11 +23,6 @@ var __extends = (this && this.__extends) || (function () {
2323
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2424
};
2525
})();
26-
var x;
27-
if (typeof x !== "string") {
28-
x[0] = "";
29-
x[0] = new StringTreeCollection;
30-
}
3126
var StringTreeCollectionBase = (function () {
3227
function StringTreeCollectionBase() {
3328
}
@@ -40,3 +35,8 @@ var StringTreeCollection = (function (_super) {
4035
}
4136
return StringTreeCollection;
4237
}(StringTreeCollectionBase));
38+
var x;
39+
if (typeof x !== "string") {
40+
x[0] = "";
41+
x[0] = new StringTreeCollection;
42+
}
Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
=== tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts ===
2-
var x: StringTree;
3-
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3))
4-
>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1))
5-
6-
if (typeof x !== "string") {
7-
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3))
8-
9-
x[0] = "";
10-
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3))
11-
12-
x[0] = new StringTreeCollection;
13-
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3))
14-
>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1))
15-
}
16-
172
type StringTree = string | StringTreeCollection;
18-
>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1))
19-
>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1))
3+
>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0))
4+
>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1))
205

216
class StringTreeCollectionBase {
22-
>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 6, 48))
7+
>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 0, 48))
238

249
[n: number]: StringTree;
25-
>n : Symbol(n, Decl(classDoesNotDependOnBaseTypes.ts, 8, 5))
26-
>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1))
10+
>n : Symbol(n, Decl(classDoesNotDependOnBaseTypes.ts, 2, 5))
11+
>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0))
2712
}
2813

2914
class StringTreeCollection extends StringTreeCollectionBase { }
30-
>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1))
31-
>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 6, 48))
15+
>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1))
16+
>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 0, 48))
3217

18+
var x: StringTree;
19+
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3))
20+
>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0))
21+
22+
if (typeof x !== "string") {
23+
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3))
24+
25+
x[0] = "";
26+
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3))
27+
28+
x[0] = new StringTreeCollection;
29+
>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3))
30+
>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1))
31+
}

tests/baselines/reference/classDoesNotDependOnBaseTypes.types

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
=== tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts ===
2+
type StringTree = string | StringTreeCollection;
3+
>StringTree : StringTree
4+
>StringTreeCollection : StringTreeCollection
5+
6+
class StringTreeCollectionBase {
7+
>StringTreeCollectionBase : StringTreeCollectionBase
8+
9+
[n: number]: StringTree;
10+
>n : number
11+
>StringTree : StringTree
12+
}
13+
14+
class StringTreeCollection extends StringTreeCollectionBase { }
15+
>StringTreeCollection : StringTreeCollection
16+
>StringTreeCollectionBase : StringTreeCollectionBase
17+
218
var x: StringTree;
319
>x : StringTree
420
>StringTree : StringTree
@@ -24,20 +40,3 @@ if (typeof x !== "string") {
2440
>new StringTreeCollection : StringTreeCollection
2541
>StringTreeCollection : typeof StringTreeCollection
2642
}
27-
28-
type StringTree = string | StringTreeCollection;
29-
>StringTree : StringTree
30-
>StringTreeCollection : StringTreeCollection
31-
32-
class StringTreeCollectionBase {
33-
>StringTreeCollectionBase : StringTreeCollectionBase
34-
35-
[n: number]: StringTree;
36-
>n : number
37-
>StringTree : StringTree
38-
}
39-
40-
class StringTreeCollection extends StringTreeCollectionBase { }
41-
>StringTreeCollection : StringTreeCollection
42-
>StringTreeCollectionBase : StringTreeCollectionBase
43-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts(2,21): error TS2449: Class 'C' used before its declaration.
2+
3+
4+
==== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts (1 errors) ====
5+
6+
var before: C = new C();
7+
~
8+
!!! error TS2449: Class 'C' used before its declaration.
9+
10+
export default class C {
11+
method(): C {
12+
return new C();
13+
}
14+
}
15+
16+
var after: C = new C();
17+
18+
var t: typeof C = C;
19+
20+

tests/baselines/reference/es5ExportDefaultClassDeclaration3.symbols

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/baselines/reference/es5ExportDefaultClassDeclaration3.types

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its declaration.
2+
3+
4+
==== tests/cases/compiler/exportAssignmentOfGenericType1_1.ts (0 errors) ====
5+
///<reference path='exportAssignmentOfGenericType1_0.ts'/>
6+
import q = require("exportAssignmentOfGenericType1_0");
7+
8+
class M extends q<string> { }
9+
var m: M;
10+
var r: string = m.foo;
11+
12+
==== tests/cases/compiler/exportAssignmentOfGenericType1_0.ts (1 errors) ====
13+
export = T;
14+
~
15+
!!! error TS2449: Class 'T' used before its declaration.
16+
class T<X> { foo: X; }
17+
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
1+
tests/cases/conformance/es6/for-ofStatements/for-of14.ts(8,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
22

33

44
==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ====
5-
var v: string;
6-
for (v of new StringIterator) { } // Should fail because the iterator is not iterable
7-
~~~~~~~~~~~~~~~~~~
8-
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
9-
105
class StringIterator {
116
next() {
127
return "";
138
}
14-
}
9+
}
10+
11+
var v: string;
12+
for (v of new StringIterator) { } // Should fail because the iterator is not iterable
13+
~~~~~~~~~~~~~~~~~~
14+
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.

0 commit comments

Comments
 (0)