2014-07-13 01:04:16 +02:00
|
|
|
//// [typeIdentityConsidersBrands.ts]
|
|
|
|
class X{
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Y{
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class X_1 {
|
|
|
|
private name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Y_1 {
|
|
|
|
private name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo(arg: X){}
|
|
|
|
|
|
|
|
var a = new Y();
|
|
|
|
var b = new X();
|
|
|
|
|
|
|
|
a = b; // ok
|
|
|
|
foo(a); // ok
|
|
|
|
|
|
|
|
var a2 = new Y_1();
|
|
|
|
var b2 = new X_1();
|
|
|
|
|
|
|
|
function foo2(arg: X_1) { }
|
|
|
|
|
|
|
|
a2 = b2; // should error
|
|
|
|
foo2(a2); // should error
|
|
|
|
|
|
|
|
|
|
|
|
//// [typeIdentityConsidersBrands.js]
|
|
|
|
var X = (function () {
|
|
|
|
function X() {
|
|
|
|
}
|
|
|
|
return X;
|
|
|
|
})();
|
|
|
|
var Y = (function () {
|
|
|
|
function Y() {
|
|
|
|
}
|
|
|
|
return Y;
|
|
|
|
})();
|
|
|
|
var X_1 = (function () {
|
|
|
|
function X_1() {
|
|
|
|
}
|
|
|
|
return X_1;
|
|
|
|
})();
|
|
|
|
var Y_1 = (function () {
|
|
|
|
function Y_1() {
|
|
|
|
}
|
|
|
|
return Y_1;
|
|
|
|
})();
|
2015-02-07 03:45:09 +01:00
|
|
|
function foo(arg) { }
|
2014-07-13 01:04:16 +02:00
|
|
|
var a = new Y();
|
|
|
|
var b = new X();
|
2014-08-16 00:49:09 +02:00
|
|
|
a = b; // ok
|
|
|
|
foo(a); // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
var a2 = new Y_1();
|
|
|
|
var b2 = new X_1();
|
2015-02-07 03:45:09 +01:00
|
|
|
function foo2(arg) { }
|
2014-08-16 00:49:09 +02:00
|
|
|
a2 = b2; // should error
|
|
|
|
foo2(a2); // should error
|