-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Spurious 'Index signature is missing in type' error when subclassing #1887
Comments
I ran into a variation of this with properties and static properties that is affecting me:
|
Seems related. In my case the error goes away when foo() : Indexer {
return { id: 10 };
} One shouldn't have to do this. |
This looks to be a duplicate of #1373 |
The last piece of the puzzle is that subclass methods are not contextually typed by their base class function signatures. (aaand Anders referenced issue I was about to link once I found it) |
Yes, I see that now. It's all the more confusing because the error message contains information about the mismatch between the base and subclasses. And one is left scratching their head thinking "if the compiler already knows about this, why then is it complaining?!" I keep getting tripped up by the contextual typing of objects with index signatures. (I feel I've been referred to that SO post before!) The fact that it has taken a long post on StackOverflow kind of hints at the usability issues surrounding this. Nevertheless it's a very informative response. Thanks! |
Can anyone help me with this scenario please |
Hi,
TS: 1.4
Not sure that I agree we should have an error here:
The text was updated successfully, but these errors were encountered: