Skip to content
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

Type inference not working properly in certain case #33826

Closed
mcjazzyfunky opened this issue Oct 5, 2019 · 2 comments
Closed

Type inference not working properly in certain case #33826

mcjazzyfunky opened this issue Oct 5, 2019 · 2 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@mcjazzyfunky
Copy link

mcjazzyfunky commented Oct 5, 2019

TypeScript Version:
3.6.3 (same for 3.7-beta)

Code
Please click on the playground link below and you will find three demos of things that should behave basically the same. While type inference is working fine in 'Demo 2' and 'Demo 3' it is not working properly in 'Demo 1'. The demo provides a simple fantasy API for implementing UI components - please ignore whether this demo API makes any sense or not - the semantic is completely unimportant here - it's only about the type system/inference here.

Expected behavior:
Type inference in 'Demo 1' should work the same as in 'Demo 2' and 'Demo 3' regarding functions getState and setState (see code).

Actual behavior:
In 'Demo 1' type inference fails for getState and setState (see code)

Playground Link:
Please find the demo here: DEMO

Related Issues:
This may marginally be related to feature request #16597, as I would have written the demos slightly differently if that feature requested in #16597 would already have been implemented. BTW, IMHO this 16597 feature is the most important missing feature in TS ... just saying ;-)

@RyanCavanaugh RyanCavanaugh added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Oct 17, 2019
@RyanCavanaugh
Copy link
Member

The example here would require unification to work; see #30134

@mcjazzyfunky
Copy link
Author

Many thanks, Ryan.
As this is already handled in that "Full unification for generic interface" issue, I think it's best to close this issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

2 participants