2014-07-13 01:04:16 +02:00
|
|
|
//// [genericObjectLitReturnType.ts]
|
|
|
|
class X<T>
|
|
|
|
{
|
|
|
|
f(t: T) { return { a: t }; }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var x: X<number>;
|
|
|
|
var t1 = x.f(5);
|
|
|
|
t1.a = 5; // Should not error: t1 should have type {a: number}, instead has type {a: T}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// [genericObjectLitReturnType.js]
|
|
|
|
var X = (function () {
|
|
|
|
function X() {
|
|
|
|
}
|
|
|
|
X.prototype.f = function (t) {
|
|
|
|
return { a: t };
|
|
|
|
};
|
|
|
|
return X;
|
|
|
|
})();
|
|
|
|
var x;
|
|
|
|
var t1 = x.f(5);
|
2014-08-16 00:49:09 +02:00
|
|
|
t1.a = 5; // Should not error: t1 should have type {a: number}, instead has type {a: T}
|