Merge pull request #6763 from Microsoft/classInterfaceCrossFileMerge

properly handle merged declarations across files
This commit is contained in:
Vladimir Matveev
2016-02-01 10:00:54 -08:00
parent b4bb5f3379
commit e67f7bc830
9 changed files with 241 additions and 4 deletions

View File

@@ -0,0 +1,34 @@
//// [tests/cases/compiler/mergedDeclarations5.ts] ////
//// [a.ts]
class A {
protected foo() {}
}
//// [b.ts]
interface A { }
class B extends A {
protected foo() {}
}
//// [a.js]
var A = (function () {
function A() {
}
A.prototype.foo = function () { };
return A;
}());
//// [b.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
B.prototype.foo = function () { };
return B;
}(A));

View File

@@ -0,0 +1,18 @@
=== tests/cases/compiler/a.ts ===
class A {
>A : Symbol(A, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
protected foo() {}
>foo : Symbol(foo, Decl(a.ts, 0, 9))
}
=== tests/cases/compiler/b.ts ===
interface A { }
>A : Symbol(A, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
class B extends A {
>B : Symbol(B, Decl(b.ts, 0, 15))
>A : Symbol(A, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
protected foo() {}
>foo : Symbol(foo, Decl(b.ts, 2, 19))
}

View File

@@ -0,0 +1,18 @@
=== tests/cases/compiler/a.ts ===
class A {
>A : A
protected foo() {}
>foo : () => void
}
=== tests/cases/compiler/b.ts ===
interface A { }
>A : A
class B extends A {
>B : B
>A : A
protected foo() {}
>foo : () => void
}

View File

@@ -0,0 +1,57 @@
//// [tests/cases/compiler/mergedDeclarations6.ts] ////
//// [a.ts]
export class A {
protected protected: any;
protected setProtected(val: any) {
this.protected = val;
}
}
//// [b.ts]
import {A} from './a';
declare module "./a" {
interface A { }
}
export class B extends A {
protected setProtected() {
}
}
//// [a.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var A = (function () {
function A() {
}
A.prototype.setProtected = function (val) {
this.protected = val;
};
return A;
}());
exports.A = A;
});
//// [b.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
define(["require", "exports", './a'], function (require, exports, a_1) {
"use strict";
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
B.prototype.setProtected = function () {
};
return B;
}(a_1.A));
exports.B = B;
});

View File

@@ -0,0 +1,38 @@
=== tests/cases/compiler/a.ts ===
export class A {
>A : Symbol(A, Decl(a.ts, 0, 0), Decl(b.ts, 2, 22))
protected protected: any;
>protected : Symbol(protected, Decl(a.ts, 1, 16))
protected setProtected(val: any) {
>setProtected : Symbol(setProtected, Decl(a.ts, 2, 29))
>val : Symbol(val, Decl(a.ts, 4, 27))
this.protected = val;
>this.protected : Symbol(protected, Decl(a.ts, 1, 16))
>this : Symbol(A, Decl(a.ts, 0, 0), Decl(b.ts, 2, 22))
>protected : Symbol(protected, Decl(a.ts, 1, 16))
>val : Symbol(val, Decl(a.ts, 4, 27))
}
}
=== tests/cases/compiler/b.ts ===
import {A} from './a';
>A : Symbol(A, Decl(b.ts, 0, 8))
declare module "./a" {
interface A { }
>A : Symbol(A, Decl(a.ts, 0, 0), Decl(b.ts, 2, 22))
}
export class B extends A {
>B : Symbol(B, Decl(b.ts, 4, 1))
>A : Symbol(A, Decl(b.ts, 0, 8))
protected setProtected() {
>setProtected : Symbol(setProtected, Decl(b.ts, 6, 26))
}
}

View File

@@ -0,0 +1,39 @@
=== tests/cases/compiler/a.ts ===
export class A {
>A : A
protected protected: any;
>protected : any
protected setProtected(val: any) {
>setProtected : (val: any) => void
>val : any
this.protected = val;
>this.protected = val : any
>this.protected : any
>this : this
>protected : any
>val : any
}
}
=== tests/cases/compiler/b.ts ===
import {A} from './a';
>A : typeof A
declare module "./a" {
interface A { }
>A : A
}
export class B extends A {
>B : B
>A : A
protected setProtected() {
>setProtected : () => void
}
}