Closed
Description
This may relate to #10288
TypeScript Version: 2.0.0, installed via typescript@beta
Code
All code under --noImplicitThis
flag.
function plainThisBound(m: {[k:string]: (this: string) => string}) {}
plainThisBound({
method() {
return this.substr(0) // no error
}
})
function polymorphicThisBound(m: {[k:string]: <V>(this: string) => V}) {}
polymorphicThisBound({
method() {
return this.substr(0) // error in noImplicitThis
}
})
function unionThisBound(m: {[k:string]: (this: string) => string} & {method(): string}) {}
unionThisBound({
method() {
return this.substr(0) // error in noImplicitThis
}
})
Expected behavior:
All three example should compile, if this
parameter is inferred on call site
Or no example should compile, if this
must be explicitly annotated
Actual behavior:
Only the first example compiles.