-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
React 16.6 types #29989
Comments
@Kovensky you can use something like that for getDerivedStateFromProps:
|
The problem is that that |
Wow, bad news for me( Thank you for explanation. |
What version of |
I'm looking at our company package.json and it's unexpectedly hard to install/update @types packages that matches the actual packages. I hope this change some day! for now, any help on this issue would be great :) |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
React 16.6 was released today: https://reactjs.org/blog/2018/10/23/react-v-16-6.html
I would have made this as a PR, but there is a problem with the new
static contextType
feature that I don't know how to solve. This is probably a TypeScript core problem.First, the type of
context
is defined inclass Component
and marked as@deprecated
(which triggers thedeprecation
tslint rule), butcontext
is only deprecated ifstatic contextType
is not defined.Second, the type of
this.context
depends on the type ofstatic contextType
, and there is no way I can think of, within TypeScript's generic system, declaring that in the types. While I can hack that intoComponentClass
's definition, it wouldn't help actually subclassingComponent
correctly.Probably the only solution that would work short term is removing the
context: any
declaration entirely, but it'd be a breaking change.This is not the first time we hit limitations of the generic system in React; see
getDerivedStateFromProps
which had to be left out ofComponent
's definition entirely because it'd just have to haveany
inputs and outputs anyway.The text was updated successfully, but these errors were encountered: