Closed
Description
Sorry for the undescriptive title but the behavior is too strange for me to describe...
Related to #9673 and #9746 with subtle difference
Maybe it's still problem for instantiating this
? @sandersn
TypeScript Version: 2.0.0
Code
Declaration
// A *self-contained* demonstration of the problem follows...
declare class VueTyped<T> {
data<D>(d: D): VueTyped<T & D>;
method<M extends { [k:string]: (this: T) => ({} | void) }>(m: M): VueTyped<T & M>
static init(): VueTyped<{}>
}
Usage:
When under --noImplicitThis
flag, this code reports this
has implicit any
.
No error when implictThis
is allowed.
VueTyped.init()
.data({msg: '123'})
.method({
method() {
this.msgs.length // error here but reported wrongly
return this.msg
}
})
Another usage:
When return value isn't from this
, compiler has a false alarm.
VueTyped.init()
.data({msg: '123'})
.method({
method() {
this.msg // error her but should not
return '123'
}
})
Expected behavior:
For the first usage, this.msgs
should trigger Property not exist
error.
For the second usage, this.msg
should not report any error.
Actual behavior:
No implicit this errors for both.