Skip to content

Commit 92b18d8

Browse files
authored
Merge pull request #24052 from RyanCavanaugh/portInitializerFix
Port fix #24050 from master to release-2.8
2 parents 80fff90 + e03e2ae commit 92b18d8

File tree

4 files changed

+56
-52
lines changed

4 files changed

+56
-52
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,12 @@ namespace ts {
894894
}
895895
if ((source.flags | target.flags) & SymbolFlags.JSContainer) {
896896
const sourceInitializer = getJSInitializerSymbol(source);
897-
const targetInitializer = getJSInitializerSymbol(target);
897+
let targetInitializer = getJSInitializerSymbol(target);
898898
if (sourceInitializer !== source || targetInitializer !== target) {
899+
if (!(targetInitializer.flags & SymbolFlags.Transient)) {
900+
const mergedInitializer = getMergedSymbol(targetInitializer);
901+
targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer;
902+
}
899903
mergeSymbol(targetInitializer, sourceInitializer);
900904
}
901905
}
@@ -18779,7 +18783,7 @@ namespace ts {
1877918783
}
1878018784

1878118785
const links = getNodeLinks(node);
18782-
const type = getTypeOfSymbol(node.symbol);
18786+
const type = getTypeOfSymbol(getMergedSymbol(node.symbol));
1878318787

1878418788
// Check if function expression is contextually typed and assign parameter types if so.
1878518789
if (!(links.flags & NodeCheckFlags.ContextChecked)) {

tests/baselines/reference/typeFromPropertyAssignment10.types

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
=== tests/cases/conformance/salsa/module.js ===
22
var Outer = Outer || {};
3-
>Outer : typeof __object
4-
>Outer || {} : typeof __object
5-
>Outer : typeof __object
6-
>{} : typeof __object
3+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
4+
>Outer || {} : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
5+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
6+
>{} : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
77

88
Outer.app = Outer.app || {};
9-
>Outer.app = Outer.app || {} : typeof __object
10-
>Outer.app : typeof __object
11-
>Outer : typeof __object
12-
>app : typeof __object
13-
>Outer.app || {} : typeof __object
14-
>Outer.app : typeof __object
15-
>Outer : typeof __object
16-
>app : typeof __object
17-
>{} : typeof __object
9+
>Outer.app = Outer.app || {} : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
10+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
11+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
12+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
13+
>Outer.app || {} : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
14+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
15+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
16+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
17+
>{} : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
1818

1919
=== tests/cases/conformance/salsa/someview.js ===
2020
Outer.app.SomeView = (function () {
2121
>Outer.app.SomeView = (function () { var SomeView = function() { var me = this; } return SomeView;})() : () => void
2222
>Outer.app.SomeView : () => void
23-
>Outer.app : typeof __object
24-
>Outer : typeof __object
25-
>app : typeof __object
23+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
24+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
25+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
2626
>SomeView : () => void
2727
>(function () { var SomeView = function() { var me = this; } return SomeView;})() : () => void
2828
>(function () { var SomeView = function() { var me = this; } return SomeView;}) : () => () => void
@@ -43,9 +43,9 @@ Outer.app.SomeView = (function () {
4343
Outer.app.Inner = class {
4444
>Outer.app.Inner = class { constructor() { /** @type {number} */ this.y = 12; }} : typeof (Anonymous class)
4545
>Outer.app.Inner : typeof (Anonymous class)
46-
>Outer.app : typeof __object
47-
>Outer : typeof __object
48-
>app : typeof __object
46+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
47+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
48+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
4949
>Inner : typeof (Anonymous class)
5050
>class { constructor() { /** @type {number} */ this.y = 12; }} : typeof (Anonymous class)
5151

@@ -63,9 +63,9 @@ var example = new Outer.app.Inner();
6363
>example : (Anonymous class)
6464
>new Outer.app.Inner() : (Anonymous class)
6565
>Outer.app.Inner : typeof (Anonymous class)
66-
>Outer.app : typeof __object
67-
>Outer : typeof __object
68-
>app : typeof __object
66+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
67+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
68+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
6969
>Inner : typeof (Anonymous class)
7070

7171
example.y;
@@ -77,9 +77,9 @@ example.y;
7777
Outer.app.statische = function (k) {
7878
>Outer.app.statische = function (k) { return k ** k;} : (k: number) => number
7979
>Outer.app.statische : (k: number) => number
80-
>Outer.app : typeof __object
81-
>Outer : typeof __object
82-
>app : typeof __object
80+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
81+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
82+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
8383
>statische : (k: number) => number
8484
>function (k) { return k ** k;} : (k: number) => number
8585
>k : number
@@ -93,9 +93,9 @@ Outer.app.statische = function (k) {
9393
Outer.app.Application = (function () {
9494
>Outer.app.Application = (function () { /** * Application main class. * Will be instantiated & initialized by HTML page */ var Application = function () { var me = this; me.view = new Outer.app.SomeView(); }; return Application;})() : () => void
9595
>Outer.app.Application : () => void
96-
>Outer.app : typeof __object
97-
>Outer : typeof __object
98-
>app : typeof __object
96+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
97+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
98+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
9999
>Application : () => void
100100
>(function () { /** * Application main class. * Will be instantiated & initialized by HTML page */ var Application = function () { var me = this; me.view = new Outer.app.SomeView(); }; return Application;})() : () => void
101101
>(function () { /** * Application main class. * Will be instantiated & initialized by HTML page */ var Application = function () { var me = this; me.view = new Outer.app.SomeView(); }; return Application;}) : () => () => void
@@ -120,9 +120,9 @@ Outer.app.Application = (function () {
120120
>view : any
121121
>new Outer.app.SomeView() : any
122122
>Outer.app.SomeView : () => void
123-
>Outer.app : typeof __object
124-
>Outer : typeof __object
125-
>app : typeof __object
123+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
124+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
125+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
126126
>SomeView : () => void
127127

128128
};
@@ -135,18 +135,18 @@ var app = new Outer.app.Application();
135135
>app : any
136136
>new Outer.app.Application() : any
137137
>Outer.app.Application : () => void
138-
>Outer.app : typeof __object
139-
>Outer : typeof __object
140-
>app : typeof __object
138+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
139+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
140+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
141141
>Application : () => void
142142

143143
var inner = new Outer.app.Inner();
144144
>inner : (Anonymous class)
145145
>new Outer.app.Inner() : (Anonymous class)
146146
>Outer.app.Inner : typeof (Anonymous class)
147-
>Outer.app : typeof __object
148-
>Outer : typeof __object
149-
>app : typeof __object
147+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
148+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
149+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
150150
>Inner : typeof (Anonymous class)
151151

152152
inner.y;
@@ -166,9 +166,9 @@ x.y;
166166
Outer.app.statische(101); // Infinity, duh
167167
>Outer.app.statische(101) : number
168168
>Outer.app.statische : (k: number) => number
169-
>Outer.app : typeof __object
170-
>Outer : typeof __object
171-
>app : typeof __object
169+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
170+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
171+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
172172
>statische : (k: number) => number
173173
>101 : 101
174174

tests/baselines/reference/typeFromPropertyAssignment14.types

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
=== tests/cases/conformance/salsa/def.js ===
22
var Outer = {};
3-
>Outer : typeof Outer
4-
>{} : typeof Outer
3+
>Outer : { [x: string]: any; Inner: () => void; }
4+
>{} : { [x: string]: any; Inner: () => void; }
55

66
=== tests/cases/conformance/salsa/work.js ===
77
Outer.Inner = function () {}
88
>Outer.Inner = function () {} : () => void
99
>Outer.Inner : () => void
10-
>Outer : typeof Outer
10+
>Outer : { [x: string]: any; Inner: () => void; }
1111
>Inner : () => void
1212
>function () {} : () => void
1313

1414
Outer.Inner.prototype = {
1515
>Outer.Inner.prototype = { x: 1, m() { }} : { [x: string]: any; x: number; m(): void; }
1616
>Outer.Inner.prototype : any
1717
>Outer.Inner : () => void
18-
>Outer : typeof Outer
18+
>Outer : { [x: string]: any; Inner: () => void; }
1919
>Inner : () => void
2020
>prototype : any
2121
>{ x: 1, m() { }} : { [x: string]: any; x: number; m(): void; }
@@ -48,7 +48,7 @@ var inno = new Outer.Inner()
4848
>inno : { [x: string]: any; x: number; m(): void; }
4949
>new Outer.Inner() : { [x: string]: any; x: number; m(): void; }
5050
>Outer.Inner : () => void
51-
>Outer : typeof Outer
51+
>Outer : { [x: string]: any; Inner: () => void; }
5252
>Inner : () => void
5353

5454
inno.x

tests/baselines/reference/typeFromPropertyAssignment4.types

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
=== tests/cases/conformance/salsa/def.js ===
22
var Outer = {};
3-
>Outer : typeof Outer
4-
>{} : typeof Outer
3+
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
4+
>{} : { [x: string]: any; Inner: typeof (Anonymous class); }
55

66
=== tests/cases/conformance/salsa/a.js ===
77
Outer.Inner = class {
88
>Outer.Inner = class { constructor() { /** @type {number} */ this.y = 12 }} : typeof (Anonymous class)
99
>Outer.Inner : typeof (Anonymous class)
10-
>Outer : typeof Outer
10+
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
1111
>Inner : typeof (Anonymous class)
1212
>class { constructor() { /** @type {number} */ this.y = 12 }} : typeof (Anonymous class)
1313

@@ -35,7 +35,7 @@ var inner = new Outer.Inner()
3535
>inner : (Anonymous class)
3636
>new Outer.Inner() : (Anonymous class)
3737
>Outer.Inner : typeof (Anonymous class)
38-
>Outer : typeof Outer
38+
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
3939
>Inner : typeof (Anonymous class)
4040

4141
inner.y
@@ -57,7 +57,7 @@ var z = new Outer.Inner()
5757
>z : (Anonymous class)
5858
>new Outer.Inner() : (Anonymous class)
5959
>Outer.Inner : typeof (Anonymous class)
60-
>Outer : typeof Outer
60+
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
6161
>Inner : typeof (Anonymous class)
6262

6363
z.y

0 commit comments

Comments
 (0)