Description
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 ;-)