2014-07-13 01:04:16 +02:00
|
|
|
//// [genericTypeAssertions1.ts]
|
|
|
|
class A<T> { foo(x: T) { }}
|
|
|
|
var foo = new A<number>();
|
|
|
|
var r: A<string> = <A<number>>new A(); // error
|
|
|
|
var r2: A<number> = <A<A<number>>>foo; // error
|
|
|
|
|
|
|
|
//// [genericTypeAssertions1.js]
|
|
|
|
var A = (function () {
|
|
|
|
function A() {
|
|
|
|
}
|
2015-02-07 03:45:09 +01:00
|
|
|
A.prototype.foo = function (x) { };
|
2014-07-13 01:04:16 +02:00
|
|
|
return A;
|
|
|
|
})();
|
|
|
|
var foo = new A();
|
2014-08-15 22:18:54 +02:00
|
|
|
var r = new A(); // error
|
2014-08-15 23:32:08 +02:00
|
|
|
var r2 = foo; // error
|