-
Notifications
You must be signed in to change notification settings - Fork 12.8k
this reference in Object #10410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
it seems correct to me as Try writing this way: interface IFoo {
get(val: number): number;
getAll(val: string): number;
}
function foo(): IFoo {
const get = function(val: number): number {
return val + 1;
};
const getAll = function(val: string): number {
return get(val)*10;
}
return {
get, getAll
};
} And btw, your "Trick to get expected behavior" does not works neither. |
See #6739 for work in this area, though I don't think all of it is going into 2.0. |
@nippur72 's comment is correct. You can use an arrow function to actually preserve |
sorry Trick to get expected behavior should be: interface IFoo {
get(val: number): number;
getAll(val: string): number;
}
function foo(): IFoo {
var a: IFoo = {
get(val: number): number {
return val + 1;
},
getAll(val: string): number {
return a.get(val)*10;
}
};
return a;
} :) |
TypeScript Version: 1.8.0 / nightly (2.0.0-dev.201xxxxx)
Code
Expected behavior:
Compiler show an error that val string isn't a number
Actual behavior:
No error.
Trick to get expected behavior:
The text was updated successfully, but these errors were encountered: