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

Prepare Component Props for more strict restrictions #602

Merged
merged 2 commits into from
Aug 8, 2021

Conversation

sgrishchenko
Copy link
Collaborator

There are typing vulnerability of currents props: every component now can have children with type Array<ReactNode>, even it is not declared obviously. Also there is conflict of names and now there are difficulties with creation of children with custom type (e.g. render children)
This PR - first step to make Props more strict.
TS typings
Part of #358
cc @turansky @aerialist7

@@ -13,8 +13,8 @@ external interface QueryErrorResetBoundaryValue {

external val useQueryErrorResetBoundary: () -> QueryErrorResetBoundaryValue

external interface QueryErrorResetBoundaryProps : react.RProps {
var children: dynamic
external interface QueryErrorResetBoundaryProps : react.Props {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropsWithChildren? I will fix it in generator

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://react-query.tanstack.com/reference/QueryErrorResetBoundary
There should be render children, not Array<ReactNode>

@@ -16,10 +16,6 @@ abstract class RComponent<P : RProps, S : State> : Component<P, S> {
// if you use this method, don't forget to pass props to the constructor first
open fun S.init(props: P) {}

fun RBuilder.children() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant?

Copy link
Collaborator Author

@sgrishchenko sgrishchenko Aug 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, there is context(RBuilder) PropsWithChildren.children(), this declaration in more obvious, it is impossible to declare such method in RComponent because we don't know will inheritor implements PropsWithChildren or not

external interface QueryErrorResetBoundaryProps : react.RProps {
var children: dynamic
external interface QueryErrorResetBoundaryProps : react.Props {
var children: dynamic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишний пробел

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will regenerate react-query wrappers after this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed anyway

@Leonya Leonya merged commit 5235e24 into JetBrains:master Aug 8, 2021
@Leonya
Copy link
Collaborator

Leonya commented Aug 8, 2021

Released in pre.228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants