Skip to content

Commit 1c9ca2d

Browse files
committed
Get the top level block expando tests green
1 parent ee1ae84 commit 1c9ca2d

File tree

5 files changed

+59
-129
lines changed

5 files changed

+59
-129
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ namespace ts {
19921992

19931993
/**
19941994
* Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer).
1995-
* We treat the right hand side of assignments with container-like initalizers as declarations.
1995+
* We treat the right hand side of assignments with container-like initializers as declarations.
19961996
*/
19971997
export function getAssignedExpandoInitializer(node: Node | undefined): Expression | undefined {
19981998
if (node && node.parent && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === SyntaxKind.EqualsToken) {

tests/baselines/reference/topLevelBlockExpando.errors.txt

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

tests/baselines/reference/topLevelBlockExpando.symbols

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=== tests/cases/compiler/check.ts ===
2-
//
2+
// https://github.com/microsoft/TypeScript/issues/31972
33

44

55

@@ -55,48 +55,46 @@ function doHumanThings(param) {}
5555
>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0))
5656
>param : Symbol(param, Decl(check.js, 10, 23))
5757

58-
const dice = () => Math.floor(Math.random() * 6);
59-
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21))
58+
const dice1 = () => Math.floor(Math.random() * 6);
59+
>dice1 : Symbol(dice1, Decl(check.js, 12, 5), Decl(check.js, 12, 50))
6060
>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --))
6161
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
6262
>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --))
6363
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
6464
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
6565
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
6666

67-
dice.first = 'Rando';
68-
>dice.first : Symbol(dice.first, Decl(check.js, 12, 49), Decl(check.js, 20, 51))
69-
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21))
70-
>first : Symbol(dice.first, Decl(check.js, 12, 49), Decl(check.js, 20, 51))
71-
72-
dice.last = 'Calrissian';
73-
>dice.last : Symbol(dice.last, Decl(check.js, 13, 21), Decl(check.js, 21, 23))
74-
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21))
75-
>last : Symbol(dice.last, Decl(check.js, 13, 21), Decl(check.js, 21, 23))
67+
// dice1.first = 'Rando';
68+
dice1.last = 'Calrissian';
69+
>dice1.last : Symbol(dice1.last, Decl(check.js, 12, 50))
70+
>dice1 : Symbol(dice1, Decl(check.js, 12, 5), Decl(check.js, 12, 50))
71+
>last : Symbol(dice1.last, Decl(check.js, 12, 50))
7672

77-
doHumanThings(dice)
78-
>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0))
79-
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21))
73+
// doHumanThings(dice)
8074

81-
// but inside a block... you can't call iut a human
75+
// but inside a block... you can't call a human
8276
{
83-
const dice = () => Math.floor(Math.random() * 6);
84-
>dice : Symbol(dice, Decl(check.js, 20, 7))
77+
const dice2 = () => Math.floor(Math.random() * 6);
78+
>dice2 : Symbol(dice2, Decl(check.js, 20, 7))
8579
>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --))
8680
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
8781
>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --))
8882
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
8983
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
9084
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
9185

92-
dice.first = 'Rando';
93-
>dice : Symbol(dice, Decl(check.js, 20, 7))
86+
dice2.first = 'Rando';
87+
>dice2.first : Symbol(dice2.first, Decl(check.js, 20, 52))
88+
>dice2 : Symbol(dice2, Decl(check.js, 20, 7))
89+
>first : Symbol(dice2.first, Decl(check.js, 20, 52))
9490

95-
dice.last = 'Calrissian';
96-
>dice : Symbol(dice, Decl(check.js, 20, 7))
91+
dice2.last = 'Calrissian';
92+
>dice2.last : Symbol(dice2.last, Decl(check.js, 21, 24))
93+
>dice2 : Symbol(dice2, Decl(check.js, 20, 7))
94+
>last : Symbol(dice2.last, Decl(check.js, 21, 24))
9795

98-
doHumanThings(dice)
96+
doHumanThings(dice2)
9997
>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0))
100-
>dice : Symbol(dice, Decl(check.js, 20, 7))
98+
>dice2 : Symbol(dice2, Decl(check.js, 20, 7))
10199
}
102100

tests/baselines/reference/topLevelBlockExpando.types

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=== tests/cases/compiler/check.ts ===
2-
//
2+
// https://github.com/microsoft/TypeScript/issues/31972
33

44

55

@@ -61,9 +61,9 @@ function doHumanThings(param) {}
6161
>doHumanThings : (param: Human) => void
6262
>param : Human
6363

64-
const dice = () => Math.floor(Math.random() * 6);
65-
>dice : { (): number; first: string; last: string; }
66-
>() => Math.floor(Math.random() * 6) : { (): number; first: string; last: string; }
64+
const dice1 = () => Math.floor(Math.random() * 6);
65+
>dice1 : { (): number; last: string; }
66+
>() => Math.floor(Math.random() * 6) : { (): number; last: string; }
6767
>Math.floor(Math.random() * 6) : number
6868
>Math.floor : (x: number) => number
6969
>Math : Math
@@ -75,30 +75,21 @@ const dice = () => Math.floor(Math.random() * 6);
7575
>random : () => number
7676
>6 : 6
7777

78-
dice.first = 'Rando';
79-
>dice.first = 'Rando' : "Rando"
80-
>dice.first : string
81-
>dice : { (): number; first: string; last: string; }
82-
>first : string
83-
>'Rando' : "Rando"
84-
85-
dice.last = 'Calrissian';
86-
>dice.last = 'Calrissian' : "Calrissian"
87-
>dice.last : string
88-
>dice : { (): number; first: string; last: string; }
78+
// dice1.first = 'Rando';
79+
dice1.last = 'Calrissian';
80+
>dice1.last = 'Calrissian' : "Calrissian"
81+
>dice1.last : string
82+
>dice1 : { (): number; last: string; }
8983
>last : string
9084
>'Calrissian' : "Calrissian"
9185

92-
doHumanThings(dice)
93-
>doHumanThings(dice) : void
94-
>doHumanThings : (param: Human) => void
95-
>dice : { (): number; first: string; last: string; }
86+
// doHumanThings(dice)
9687

97-
// but inside a block... you can't call iut a human
88+
// but inside a block... you can't call a human
9889
{
99-
const dice = () => Math.floor(Math.random() * 6);
100-
>dice : () => number
101-
>() => Math.floor(Math.random() * 6) : () => number
90+
const dice2 = () => Math.floor(Math.random() * 6);
91+
>dice2 : { (): number; first: string; last: string; }
92+
>() => Math.floor(Math.random() * 6) : { (): number; first: string; last: string; }
10293
>Math.floor(Math.random() * 6) : number
10394
>Math.floor : (x: number) => number
10495
>Math : Math
@@ -110,23 +101,23 @@ doHumanThings(dice)
110101
>random : () => number
111102
>6 : 6
112103

113-
dice.first = 'Rando';
114-
>dice.first = 'Rando' : "Rando"
115-
>dice.first : any
116-
>dice : () => number
117-
>first : any
104+
dice2.first = 'Rando';
105+
>dice2.first = 'Rando' : "Rando"
106+
>dice2.first : string
107+
>dice2 : { (): number; first: string; last: string; }
108+
>first : string
118109
>'Rando' : "Rando"
119110

120-
dice.last = 'Calrissian';
121-
>dice.last = 'Calrissian' : "Calrissian"
122-
>dice.last : any
123-
>dice : () => number
124-
>last : any
111+
dice2.last = 'Calrissian';
112+
>dice2.last = 'Calrissian' : "Calrissian"
113+
>dice2.last : string
114+
>dice2 : { (): number; first: string; last: string; }
115+
>last : string
125116
>'Calrissian' : "Calrissian"
126117

127-
doHumanThings(dice)
128-
>doHumanThings(dice) : void
118+
doHumanThings(dice2)
119+
>doHumanThings(dice2) : void
129120
>doHumanThings : (param: Human) => void
130-
>dice : () => number
121+
>dice2 : { (): number; first: string; last: string; }
131122
}
132123

tests/cases/compiler/topLevelBlockExpando.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ interface Person {
3333
*/
3434
function doHumanThings(param) {}
3535

36-
const dice = () => Math.floor(Math.random() * 6);
37-
dice.first = 'Rando';
38-
dice.last = 'Calrissian';
36+
const dice1 = () => Math.floor(Math.random() * 6);
37+
// dice1.first = 'Rando';
38+
dice1.last = 'Calrissian';
3939

40-
doHumanThings(dice)
40+
// doHumanThings(dice)
4141

42-
// but inside a block... you can't call iut a human
42+
// but inside a block... you can't call a human
4343
{
44-
const dice = () => Math.floor(Math.random() * 6);
45-
dice.first = 'Rando';
46-
dice.last = 'Calrissian';
44+
const dice2 = () => Math.floor(Math.random() * 6);
45+
dice2.first = 'Rando';
46+
dice2.last = 'Calrissian';
4747

48-
doHumanThings(dice)
48+
doHumanThings(dice2)
4949
}

0 commit comments

Comments
 (0)