Skip to content

Commit 2d61217

Browse files
committed
add more cases
1 parent 6d8ed7b commit 2d61217

23 files changed

+936
-15
lines changed

src/harness/vfsUtil.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ namespace vfs {
663663
if (!isFile(node)) throw createIOError("EBADF");
664664

665665
const buffer = this._getBuffer(node).slice();
666-
return encoding ? buffer.toString(encoding) : buffer;
666+
return encoding ? buffer.toString(encoding as any) : buffer;
667667
}
668668

669669
/**

tests/baselines/reference/staticIndexSignature1.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
tests/cases/compiler/staticIndexSignature1.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
1+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
22

33

4-
==== tests/cases/compiler/staticIndexSignature1.ts (1 errors) ====
4+
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts (1 errors) ====
55
class C {
66
static [s: string]: number;
77
static [s: number]: 42

tests/baselines/reference/staticIndexSignature1.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=== tests/cases/compiler/staticIndexSignature1.ts ===
1+
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts ===
22
class C {
33
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0))
44

tests/baselines/reference/staticIndexSignature1.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=== tests/cases/compiler/staticIndexSignature1.ts ===
1+
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts ===
22
class C {
33
>C : C
44

tests/baselines/reference/staticIndexSignature2.errors.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/compiler/staticIndexSignature2.ts(6,1): error TS2542: Index signature in type 'typeof C' only permits reading.
2-
tests/cases/compiler/staticIndexSignature2.ts(7,1): error TS2542: Index signature in type 'typeof C' only permits reading.
3-
tests/cases/compiler/staticIndexSignature2.ts(9,1): error TS2542: Index signature in type 'typeof C' only permits reading.
4-
tests/cases/compiler/staticIndexSignature2.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
5-
tests/cases/compiler/staticIndexSignature2.ts(10,1): error TS2542: Index signature in type 'typeof C' only permits reading.
1+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(6,1): error TS2542: Index signature in type 'typeof C' only permits reading.
2+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(7,1): error TS2542: Index signature in type 'typeof C' only permits reading.
3+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(9,1): error TS2542: Index signature in type 'typeof C' only permits reading.
4+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
5+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(10,1): error TS2542: Index signature in type 'typeof C' only permits reading.
66

77

8-
==== tests/cases/compiler/staticIndexSignature2.ts (5 errors) ====
8+
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts (5 errors) ====
99
class C {
1010
static readonly [s: string]: number;
1111
static readonly [s: number]: 42

tests/baselines/reference/staticIndexSignature2.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=== tests/cases/compiler/staticIndexSignature2.ts ===
1+
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts ===
22
class C {
33
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0))
44

tests/baselines/reference/staticIndexSignature2.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
=== tests/cases/compiler/staticIndexSignature2.ts ===
1+
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts ===
22
class C {
33
>C : C
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(21,11): error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof D'.
2+
Property 'f' does not exist on type 'typeof D'.
3+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(22,11): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof D'.
4+
Property '42' does not exist on type 'typeof D'.
5+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(23,11): error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof ED'.
6+
Property 'f' does not exist on type 'typeof ED'.
7+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(24,11): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof ED'.
8+
Property '42' does not exist on type 'typeof ED'.
9+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(25,11): error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof DD'.
10+
Property 'f' does not exist on type 'typeof DD'.
11+
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(26,11): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof DD'.
12+
Property '42' does not exist on type 'typeof DD'.
13+
14+
15+
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts (6 errors) ====
16+
class B {
17+
static readonly [s: string]: number;
18+
static readonly [s: number]: 42 | 233
19+
}
20+
21+
class D extends B {
22+
static readonly [s: string]: number
23+
}
24+
25+
class ED extends D {
26+
static readonly [s: string]: boolean
27+
static readonly [s: number]: 1
28+
}
29+
30+
class DD extends D {
31+
static readonly [s: string]: 421
32+
}
33+
34+
const a = B["f"];
35+
const b = B[42];
36+
const c = D["f"]
37+
~~~~~~
38+
!!! error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof D'.
39+
!!! error TS7053: Property 'f' does not exist on type 'typeof D'.
40+
const d = D[42]
41+
~~~~~
42+
!!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof D'.
43+
!!! error TS7053: Property '42' does not exist on type 'typeof D'.
44+
const e = ED["f"]
45+
~~~~~~~
46+
!!! error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof ED'.
47+
!!! error TS7053: Property 'f' does not exist on type 'typeof ED'.
48+
const f = ED[42]
49+
~~~~~~
50+
!!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof ED'.
51+
!!! error TS7053: Property '42' does not exist on type 'typeof ED'.
52+
const g = DD["f"]
53+
~~~~~~~
54+
!!! error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof DD'.
55+
!!! error TS7053: Property 'f' does not exist on type 'typeof DD'.
56+
const h = DD[42]
57+
~~~~~~
58+
!!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof DD'.
59+
!!! error TS7053: Property '42' does not exist on type 'typeof DD'.
60+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//// [staticIndexSignature3.ts]
2+
class B {
3+
static readonly [s: string]: number;
4+
static readonly [s: number]: 42 | 233
5+
}
6+
7+
class D extends B {
8+
static readonly [s: string]: number
9+
}
10+
11+
class ED extends D {
12+
static readonly [s: string]: boolean
13+
static readonly [s: number]: 1
14+
}
15+
16+
class DD extends D {
17+
static readonly [s: string]: 421
18+
}
19+
20+
const a = B["f"];
21+
const b = B[42];
22+
const c = D["f"]
23+
const d = D[42]
24+
const e = ED["f"]
25+
const f = ED[42]
26+
const g = DD["f"]
27+
const h = DD[42]
28+
29+
30+
//// [staticIndexSignature3.js]
31+
"use strict";
32+
var __extends = (this && this.__extends) || (function () {
33+
var extendStatics = function (d, b) {
34+
extendStatics = Object.setPrototypeOf ||
35+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
37+
return extendStatics(d, b);
38+
};
39+
return function (d, b) {
40+
extendStatics(d, b);
41+
function __() { this.constructor = d; }
42+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43+
};
44+
})();
45+
var B = /** @class */ (function () {
46+
function B() {
47+
}
48+
return B;
49+
}());
50+
var D = /** @class */ (function (_super) {
51+
__extends(D, _super);
52+
function D() {
53+
return _super !== null && _super.apply(this, arguments) || this;
54+
}
55+
return D;
56+
}(B));
57+
var ED = /** @class */ (function (_super) {
58+
__extends(ED, _super);
59+
function ED() {
60+
return _super !== null && _super.apply(this, arguments) || this;
61+
}
62+
return ED;
63+
}(D));
64+
var DD = /** @class */ (function (_super) {
65+
__extends(DD, _super);
66+
function DD() {
67+
return _super !== null && _super.apply(this, arguments) || this;
68+
}
69+
return DD;
70+
}(D));
71+
var a = B["f"];
72+
var b = B[42];
73+
var c = D["f"];
74+
var d = D[42];
75+
var e = ED["f"];
76+
var f = ED[42];
77+
var g = DD["f"];
78+
var h = DD[42];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts ===
2+
class B {
3+
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))
4+
5+
static readonly [s: string]: number;
6+
>s : Symbol(s, Decl(staticIndexSignature3.ts, 1, 21))
7+
8+
static readonly [s: number]: 42 | 233
9+
>s : Symbol(s, Decl(staticIndexSignature3.ts, 2, 21))
10+
}
11+
12+
class D extends B {
13+
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))
14+
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))
15+
16+
static readonly [s: string]: number
17+
>s : Symbol(s, Decl(staticIndexSignature3.ts, 6, 21))
18+
}
19+
20+
class ED extends D {
21+
>ED : Symbol(ED, Decl(staticIndexSignature3.ts, 7, 1))
22+
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))
23+
24+
static readonly [s: string]: boolean
25+
>s : Symbol(s, Decl(staticIndexSignature3.ts, 10, 21))
26+
27+
static readonly [s: number]: 1
28+
>s : Symbol(s, Decl(staticIndexSignature3.ts, 11, 21))
29+
}
30+
31+
class DD extends D {
32+
>DD : Symbol(DD, Decl(staticIndexSignature3.ts, 12, 1))
33+
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))
34+
35+
static readonly [s: string]: 421
36+
>s : Symbol(s, Decl(staticIndexSignature3.ts, 15, 21))
37+
}
38+
39+
const a = B["f"];
40+
>a : Symbol(a, Decl(staticIndexSignature3.ts, 18, 5))
41+
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))
42+
43+
const b = B[42];
44+
>b : Symbol(b, Decl(staticIndexSignature3.ts, 19, 5))
45+
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))
46+
47+
const c = D["f"]
48+
>c : Symbol(c, Decl(staticIndexSignature3.ts, 20, 5))
49+
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))
50+
51+
const d = D[42]
52+
>d : Symbol(d, Decl(staticIndexSignature3.ts, 21, 5))
53+
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))
54+
55+
const e = ED["f"]
56+
>e : Symbol(e, Decl(staticIndexSignature3.ts, 22, 5))
57+
>ED : Symbol(ED, Decl(staticIndexSignature3.ts, 7, 1))
58+
59+
const f = ED[42]
60+
>f : Symbol(f, Decl(staticIndexSignature3.ts, 23, 5))
61+
>ED : Symbol(ED, Decl(staticIndexSignature3.ts, 7, 1))
62+
63+
const g = DD["f"]
64+
>g : Symbol(g, Decl(staticIndexSignature3.ts, 24, 5))
65+
>DD : Symbol(DD, Decl(staticIndexSignature3.ts, 12, 1))
66+
67+
const h = DD[42]
68+
>h : Symbol(h, Decl(staticIndexSignature3.ts, 25, 5))
69+
>DD : Symbol(DD, Decl(staticIndexSignature3.ts, 12, 1))
70+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts ===
2+
class B {
3+
>B : B
4+
5+
static readonly [s: string]: number;
6+
>s : string
7+
8+
static readonly [s: number]: 42 | 233
9+
>s : number
10+
}
11+
12+
class D extends B {
13+
>D : D
14+
>B : B
15+
16+
static readonly [s: string]: number
17+
>s : string
18+
}
19+
20+
class ED extends D {
21+
>ED : ED
22+
>D : D
23+
24+
static readonly [s: string]: boolean
25+
>s : string
26+
27+
static readonly [s: number]: 1
28+
>s : number
29+
}
30+
31+
class DD extends D {
32+
>DD : DD
33+
>D : D
34+
35+
static readonly [s: string]: 421
36+
>s : string
37+
}
38+
39+
const a = B["f"];
40+
>a : number
41+
>B["f"] : number
42+
>B : typeof B
43+
>"f" : "f"
44+
45+
const b = B[42];
46+
>b : 42 | 233
47+
>B[42] : 42 | 233
48+
>B : typeof B
49+
>42 : 42
50+
51+
const c = D["f"]
52+
>c : any
53+
>D["f"] : any
54+
>D : typeof D
55+
>"f" : "f"
56+
57+
const d = D[42]
58+
>d : any
59+
>D[42] : any
60+
>D : typeof D
61+
>42 : 42
62+
63+
const e = ED["f"]
64+
>e : any
65+
>ED["f"] : any
66+
>ED : typeof ED
67+
>"f" : "f"
68+
69+
const f = ED[42]
70+
>f : any
71+
>ED[42] : any
72+
>ED : typeof ED
73+
>42 : 42
74+
75+
const g = DD["f"]
76+
>g : any
77+
>DD["f"] : any
78+
>DD : typeof DD
79+
>"f" : "f"
80+
81+
const h = DD[42]
82+
>h : any
83+
>DD[42] : any
84+
>DD : typeof DD
85+
>42 : 42
86+

0 commit comments

Comments
 (0)