TypeScript Version:
nightly (1.9.0-dev.20160429)
Code
interface Factory<T> {
(): T;
mixin<U>(mixin: U): T & U;
}
function compose<T>(base: T): Factory<T> {
return;
}
const factory = compose({
foo() {
return this;
},
bar() {
this.foo(); // <-- properly contextual and literal union type
return () => {
return this; // <-- type `any`, but should be same as outside the lambda
};
}
});
const foobar = {
foo() {
return this;
},
bar() {
return () => {
return this; // <-- correct object literal type
};
}
};
Expected behavior:
That both references to this are typed the same.
Actual behavior:
I am pretty sure this is related to #8356.
Outside of the lambda function in the first object literal, this is an intersection type of the object literal and the contextual type (which happen to be the same). In the second example, this is properly the object literal type including within the scope of the lambda function.
TypeScript Version:
nightly (1.9.0-dev.20160429)
Code
Expected behavior:
That both references to
thisare typed the same.Actual behavior:
I am pretty sure this is related to #8356.
Outside of the lambda function in the first object literal,
thisis an intersection type of the object literal and the contextual type (which happen to be the same). In the second example,thisis properly the object literal type including within the scope of the lambda function.