You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it's still problem for instantiating this? @sandersn
TypeScript Version: 2.0.0
Code
Declaration
// A *self-contained* demonstration of the problem follows...declareclassVueTyped<T>{data<D>(d: D): VueTyped<T&D>;method<Mextends{[k:string]: (this: T)=>({}|void)}>(m: M): VueTyped<T&M>staticinit(): 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 wronglyreturnthis.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 notreturn'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.
The text was updated successfully, but these errors were encountered:
Shouldn't the second example trigger the error "'msg' does not exist"? As far as I can tell, this: T and T = {} based on the call to VueTyped.init(): VueTyped<{}>
Never mind, I didn't see that the definition of data: VueTyped<T & D>.
Without --noImplicitThis, I don't get an error for either case. With --noImplicitThis, I get two "this is implicitly any" errors. That's because there is no contextual this-typing happening at all. I think it's because methods aren't aware of the signature that should be coming from the string index.
Here's a simplified repro. I'm going to see if #9746 fixes this.
declarefunctioninfer<T,Mextends{[k:string]: (this: T,hunch: T)=>({}|void)}>(t: T,m: M): void;infer({msg: '123'},{method(){this.msg// error her but should notreturn'123'}})infer({msg: '123'},{method(hunch){this.msgs.length// error here but reported wronglyreturnthis.msg// shouldn't error here either}})
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
? @sandersnTypeScript Version: 2.0.0
Code
Declaration
Usage:
When under
--noImplicitThis
flag, this code reportsthis
hasimplicit any
.No error when
implictThis
is allowed.Another usage:
When return value isn't from
this
, compiler has a false alarm.Expected behavior:
For the first usage,
this.msgs
should triggerProperty not exist
error.For the second usage,
this.msg
should not report any error.Actual behavior:
No implicit this errors for both.
The text was updated successfully, but these errors were encountered: