typings: add context as 3rd type parameter for the Component interface - #1725
Open
mk0x9 wants to merge 1 commit into
Open
typings: add context as 3rd type parameter for the Component interface#1725mk0x9 wants to merge 1 commit into
mk0x9 wants to merge 1 commit into
Conversation
developit
reviewed
Jun 30, 2019
| componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; | ||
| shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean; | ||
| componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void; | ||
| componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: C): void; |
Member
There was a problem hiding this comment.
Thinking we should mark context as Readonly here like props and state are treated.
| state: Readonly<S>; | ||
| props: RenderableProps<P>; | ||
| context: any; | ||
| context: C; |
Member
There was a problem hiding this comment.
This might be odd when using contextType? Not sure. Using contextType assigns this.context to the current value of the given context provider.
Author
There was a problem hiding this comment.
You mean that it's possible to assign any Context to the static contextType? Or that contextType could be dynamically switched?
Contributor
|
It would be great if this could be looked at again. Currently using contextType does not set the type of context in a class. It does set the proper type of class.contextType. |
Thompson1985
approved these changes
Oct 6, 2024
Thompson1985
approved these changes
Oct 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So TypeScript compiler will type check it :)