Skip to content

Commit 2548ace

Browse files
committed
Add a couple of test cases
1 parent 6c74b81 commit 2548ace

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
//// [controlFlowStringIndex.ts]
2-
type A = { [index: string]: number | null };
2+
type A = {
3+
other: number | null;
4+
[index: string]: number | null
5+
};
36
declare const value: A;
47
if (value.foo !== null) {
58
value.foo.toExponential()
9+
value.other // should still be number | null
10+
value.bar // should still be number | null
611
}
712

813

914
//// [controlFlowStringIndex.js]
1015
"use strict";
1116
if (value.foo !== null) {
1217
value.foo.toExponential();
18+
value.other; // should still be number | null
19+
value.bar; // should still be number | null
1320
}
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
=== tests/cases/conformance/controlFlow/controlFlowStringIndex.ts ===
2-
type A = { [index: string]: number | null };
2+
type A = {
33
>A : Symbol(A, Decl(controlFlowStringIndex.ts, 0, 0))
4-
>index : Symbol(index, Decl(controlFlowStringIndex.ts, 0, 12))
54

5+
other: number | null;
6+
>other : Symbol(other, Decl(controlFlowStringIndex.ts, 0, 10))
7+
8+
[index: string]: number | null
9+
>index : Symbol(index, Decl(controlFlowStringIndex.ts, 2, 5))
10+
11+
};
612
declare const value: A;
7-
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 1, 13))
13+
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13))
814
>A : Symbol(A, Decl(controlFlowStringIndex.ts, 0, 0))
915

1016
if (value.foo !== null) {
11-
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 1, 13))
17+
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13))
1218

1319
value.foo.toExponential()
1420
>value.foo.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
15-
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 1, 13))
21+
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13))
1622
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
23+
24+
value.other // should still be number | null
25+
>value.other : Symbol(other, Decl(controlFlowStringIndex.ts, 0, 10))
26+
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13))
27+
>other : Symbol(other, Decl(controlFlowStringIndex.ts, 0, 10))
28+
29+
value.bar // should still be number | null
30+
>value : Symbol(value, Decl(controlFlowStringIndex.ts, 4, 13))
1731
}
1832

tests/baselines/reference/controlFlowStringIndex.types

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
=== tests/cases/conformance/controlFlow/controlFlowStringIndex.ts ===
2-
type A = { [index: string]: number | null };
2+
type A = {
33
>A : A
4+
5+
other: number | null;
6+
>other : number | null
7+
>null : null
8+
9+
[index: string]: number | null
410
>index : string
511
>null : null
612

13+
};
714
declare const value: A;
815
>value : A
916
>A : A
@@ -22,5 +29,15 @@ if (value.foo !== null) {
2229
>value : A
2330
>foo : number
2431
>toExponential : (fractionDigits?: number | undefined) => string
32+
33+
value.other // should still be number | null
34+
>value.other : number | null
35+
>value : A
36+
>other : number | null
37+
38+
value.bar // should still be number | null
39+
>value.bar : number | null
40+
>value : A
41+
>bar : number | null
2542
}
2643

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// @strict: true
2-
type A = { [index: string]: number | null };
2+
type A = {
3+
other: number | null;
4+
[index: string]: number | null
5+
};
36
declare const value: A;
47
if (value.foo !== null) {
58
value.foo.toExponential()
9+
value.other // should still be number | null
10+
value.bar // should still be number | null
611
}

0 commit comments

Comments
 (0)