-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Inference isn't working with constructor that contextually types 'this' with intersections of itself #12846
Comments
For those wondering, the reason is that the circular dependency between the type of Having discussed with @ahejlsberg, the problem is that as soon as we try to check the body of each method, the type of But since TypeScript needed to figure out the type of the |
Just so that this is easier to search for, this issue is one of the bigger ones for libraries like Vue. |
TL;DR: There should be no errors in the below example.
I am trying to model a library that takes an options bag for its constructor, and exposes those properties onto the instance that is eventually produced.
For example, if I wrote
I should be able to write
instance.hello()
orinstance.world()
.Additionally, since
this
inworld
will be bound to the instance,this.hello
should be legal and well-typed in the above example.However, I'm not able to come up with a version of this that works.
In the above example, there should be no errors - however, it appears that no inferences are being drawn as a type argument for
Methods
, and boththis.hello
andinst.hello
are causing errors.The text was updated successfully, but these errors were encountered: