Skip to content

Port fix #24050 from master to release-2.8 #24052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,12 @@ namespace ts {
}
if ((source.flags | target.flags) & SymbolFlags.JSContainer) {
const sourceInitializer = getJSInitializerSymbol(source);
const targetInitializer = getJSInitializerSymbol(target);
let targetInitializer = getJSInitializerSymbol(target);
if (sourceInitializer !== source || targetInitializer !== target) {
if (!(targetInitializer.flags & SymbolFlags.Transient)) {
const mergedInitializer = getMergedSymbol(targetInitializer);
targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer;
}
mergeSymbol(targetInitializer, sourceInitializer);
}
}
Expand Down Expand Up @@ -18779,7 +18783,7 @@ namespace ts {
}

const links = getNodeLinks(node);
const type = getTypeOfSymbol(node.symbol);
const type = getTypeOfSymbol(getMergedSymbol(node.symbol));

// Check if function expression is contextually typed and assign parameter types if so.
if (!(links.flags & NodeCheckFlags.ContextChecked)) {
Expand Down
80 changes: 40 additions & 40 deletions tests/baselines/reference/typeFromPropertyAssignment10.types
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
=== tests/cases/conformance/salsa/module.js ===
var Outer = Outer || {};
>Outer : typeof __object
>Outer || {} : typeof __object
>Outer : typeof __object
>{} : typeof __object
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>Outer || {} : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>{} : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }

Outer.app = Outer.app || {};
>Outer.app = Outer.app || {} : typeof __object
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app || {} : typeof __object
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>{} : typeof __object
>Outer.app = Outer.app || {} : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer.app || {} : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>{} : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }

=== tests/cases/conformance/salsa/someview.js ===
Outer.app.SomeView = (function () {
>Outer.app.SomeView = (function () { var SomeView = function() { var me = this; } return SomeView;})() : () => void
>Outer.app.SomeView : () => void
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>SomeView : () => void
>(function () { var SomeView = function() { var me = this; } return SomeView;})() : () => void
>(function () { var SomeView = function() { var me = this; } return SomeView;}) : () => () => void
Expand All @@ -43,9 +43,9 @@ Outer.app.SomeView = (function () {
Outer.app.Inner = class {
>Outer.app.Inner = class { constructor() { /** @type {number} */ this.y = 12; }} : typeof (Anonymous class)
>Outer.app.Inner : typeof (Anonymous class)
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Inner : typeof (Anonymous class)
>class { constructor() { /** @type {number} */ this.y = 12; }} : typeof (Anonymous class)

Expand All @@ -63,9 +63,9 @@ var example = new Outer.app.Inner();
>example : (Anonymous class)
>new Outer.app.Inner() : (Anonymous class)
>Outer.app.Inner : typeof (Anonymous class)
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Inner : typeof (Anonymous class)

example.y;
Expand All @@ -77,9 +77,9 @@ example.y;
Outer.app.statische = function (k) {
>Outer.app.statische = function (k) { return k ** k;} : (k: number) => number
>Outer.app.statische : (k: number) => number
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>statische : (k: number) => number
>function (k) { return k ** k;} : (k: number) => number
>k : number
Expand All @@ -93,9 +93,9 @@ Outer.app.statische = function (k) {
Outer.app.Application = (function () {
>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
>Outer.app.Application : () => void
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Application : () => void
>(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
>(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
Expand All @@ -120,9 +120,9 @@ Outer.app.Application = (function () {
>view : any
>new Outer.app.SomeView() : any
>Outer.app.SomeView : () => void
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>SomeView : () => void

};
Expand All @@ -135,18 +135,18 @@ var app = new Outer.app.Application();
>app : any
>new Outer.app.Application() : any
>Outer.app.Application : () => void
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Application : () => void

var inner = new Outer.app.Inner();
>inner : (Anonymous class)
>new Outer.app.Inner() : (Anonymous class)
>Outer.app.Inner : typeof (Anonymous class)
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Inner : typeof (Anonymous class)

inner.y;
Expand All @@ -166,9 +166,9 @@ x.y;
Outer.app.statische(101); // Infinity, duh
>Outer.app.statische(101) : number
>Outer.app.statische : (k: number) => number
>Outer.app : typeof __object
>Outer : typeof __object
>app : typeof __object
>Outer.app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>Outer : { [x: string]: any; app: { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }; }
>app : { [x: string]: any; SomeView: () => void; Inner: typeof (Anonymous class); statische: (k: number) => number; Application: () => void; }
>statische : (k: number) => number
>101 : 101

10 changes: 5 additions & 5 deletions tests/baselines/reference/typeFromPropertyAssignment14.types
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
=== tests/cases/conformance/salsa/def.js ===
var Outer = {};
>Outer : typeof Outer
>{} : typeof Outer
>Outer : { [x: string]: any; Inner: () => void; }
>{} : { [x: string]: any; Inner: () => void; }

=== tests/cases/conformance/salsa/work.js ===
Outer.Inner = function () {}
>Outer.Inner = function () {} : () => void
>Outer.Inner : () => void
>Outer : typeof Outer
>Outer : { [x: string]: any; Inner: () => void; }
>Inner : () => void
>function () {} : () => void

Outer.Inner.prototype = {
>Outer.Inner.prototype = { x: 1, m() { }} : { [x: string]: any; x: number; m(): void; }
>Outer.Inner.prototype : any
>Outer.Inner : () => void
>Outer : typeof Outer
>Outer : { [x: string]: any; Inner: () => void; }
>Inner : () => void
>prototype : any
>{ x: 1, m() { }} : { [x: string]: any; x: number; m(): void; }
Expand Down Expand Up @@ -48,7 +48,7 @@ var inno = new Outer.Inner()
>inno : { [x: string]: any; x: number; m(): void; }
>new Outer.Inner() : { [x: string]: any; x: number; m(): void; }
>Outer.Inner : () => void
>Outer : typeof Outer
>Outer : { [x: string]: any; Inner: () => void; }
>Inner : () => void

inno.x
Expand Down
10 changes: 5 additions & 5 deletions tests/baselines/reference/typeFromPropertyAssignment4.types
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== tests/cases/conformance/salsa/def.js ===
var Outer = {};
>Outer : typeof Outer
>{} : typeof Outer
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
>{} : { [x: string]: any; Inner: typeof (Anonymous class); }

=== tests/cases/conformance/salsa/a.js ===
Outer.Inner = class {
>Outer.Inner = class { constructor() { /** @type {number} */ this.y = 12 }} : typeof (Anonymous class)
>Outer.Inner : typeof (Anonymous class)
>Outer : typeof Outer
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
>Inner : typeof (Anonymous class)
>class { constructor() { /** @type {number} */ this.y = 12 }} : typeof (Anonymous class)

Expand Down Expand Up @@ -35,7 +35,7 @@ var inner = new Outer.Inner()
>inner : (Anonymous class)
>new Outer.Inner() : (Anonymous class)
>Outer.Inner : typeof (Anonymous class)
>Outer : typeof Outer
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
>Inner : typeof (Anonymous class)

inner.y
Expand All @@ -57,7 +57,7 @@ var z = new Outer.Inner()
>z : (Anonymous class)
>new Outer.Inner() : (Anonymous class)
>Outer.Inner : typeof (Anonymous class)
>Outer : typeof Outer
>Outer : { [x: string]: any; Inner: typeof (Anonymous class); }
>Inner : typeof (Anonymous class)

z.y
Expand Down