Skip to content

Commit 904f8df

Browse files
committed
Fix repeated merging of js initializers
1 parent c49ef36 commit 904f8df

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,8 @@ namespace ts {
918918
let targetInitializer = getJSInitializerSymbol(target);
919919
if (sourceInitializer !== source || targetInitializer !== target) {
920920
if (!(targetInitializer.flags & SymbolFlags.Transient)) {
921-
targetInitializer = cloneSymbol(targetInitializer);
921+
const mergedInitializer = getMergedSymbol(targetInitializer);
922+
targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer;
922923
}
923924
mergeSymbol(targetInitializer, sourceInitializer);
924925
}

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 Inner; statische(k: number): number; Application: () => void; }; }
4+
>Outer || {} : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
5+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
6+
>{} : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; 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 Inner; statische(k: number): number; Application: () => void; }
10+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
11+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
12+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
13+
>Outer.app || {} : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
14+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
15+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
16+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
17+
>{} : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; 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 Inner; statische(k: number): number; Application: () => void; }
24+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
25+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; 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 Inner
4545
>Outer.app.Inner : typeof Inner
46-
>Outer.app : typeof __object
47-
>Outer : typeof __object
48-
>app : typeof __object
46+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
47+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
48+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
4949
>Inner : typeof Inner
5050
>class { constructor() { /** @type {number} */ this.y = 12; }} : typeof Inner
5151

@@ -63,9 +63,9 @@ var example = new Outer.app.Inner();
6363
>example : Inner
6464
>new Outer.app.Inner() : Inner
6565
>Outer.app.Inner : typeof Inner
66-
>Outer.app : typeof __object
67-
>Outer : typeof __object
68-
>app : typeof __object
66+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
67+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
68+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
6969
>Inner : typeof Inner
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 Inner; statische(k: number): number; Application: () => void; }
81+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
82+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; 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 Inner; statische(k: number): number; Application: () => void; }
97+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
98+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; 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 Inner; statische(k: number): number; Application: () => void; }
124+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
125+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; 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 Inner; statische(k: number): number; Application: () => void; }
139+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
140+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
141141
>Application : () => void
142142

143143
var inner = new Outer.app.Inner();
144144
>inner : Inner
145145
>new Outer.app.Inner() : Inner
146146
>Outer.app.Inner : typeof Inner
147-
>Outer.app : typeof __object
148-
>Outer : typeof __object
149-
>app : typeof __object
147+
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
148+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
149+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
150150
>Inner : typeof Inner
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 Inner; statische(k: number): number; Application: () => void; }
170+
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }; }
171+
>app : { [x: string]: any; SomeView: () => void; Inner: typeof Inner; statische(k: number): number; Application: () => void; }
172172
>statische : (k: number) => number
173173
>101 : 101
174174

0 commit comments

Comments
 (0)