17 lines
407 B
TypeScript
17 lines
407 B
TypeScript
//// [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() {
|
|
}
|
|
A.prototype.foo = function (x) { };
|
|
return A;
|
|
})();
|
|
var foo = new A();
|
|
var r = new A(); // error
|
|
var r2 = foo; // error
|