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

fix(types): Add explicit types for children #1652

Closed
wants to merge 1 commit into from

Conversation

eps1lon
Copy link

@eps1lon eps1lon commented Oct 5, 2021

Summary

We plan to remove implicit types for children in @types/react@18.x. However, some of your components rely on implicit children.

Would greatly appreciate a release of 6.x so that we don't have to inline the types in the DefinitelyTyped repo

Test Plan

Changes make the relevant failures in DefinitelyTyped/DefinitelyTyped#56210 disappear

What's required for testing (prerequisites)?

npm run test-all with changes from this PR in DefinitelyTyped/DefinitelyTyped#56210

What are the steps to reproduce (after prerequisites)?

npm run test-all in DefinitelyTyped/DefinitelyTyped#56210

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)
  • I added a test for the API in the __tests__ folder

@@ -200,6 +200,7 @@ export interface LineProps extends CommonPathProps {
export const Line: React.ComponentClass<LineProps>;

export interface LinearGradientProps {
children?: React.ReactNode,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this PR concern other interfaces, which accept children as well? Or is there something special about LinearGradientProps?

Copy link
Author

@eps1lon eps1lon Mar 2, 2022

Choose a reason for hiding this comment

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

This was the only interface that needed it. Other componens are either not tested for children or they may not even support them.

Copy link
Member

Choose a reason for hiding this comment

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

What about RadialGradientProps, which then uses the same method which alters the children and right now seems to accept ReactElement[] instead of ReactNode: https://github.com/react-native-svg/react-native-svg/blob/cf808ae79db788abb7d2c03875a33920df71a3d6/src/elements/RadialGradient.tsx#L44. I am concerned about it since I made a PR with removing the index.d.ts files so the types are the same as used in component files, and it is one of the issues I encountered (see e.g. https://github.com/react-native-svg/react-native-svg/pull/1708/files#diff-1981d696a687c364c10179618dc5edf0feb68bbfa395f99c59b53e289845eec0R299 where I had to provide such type for children in order for the correct input to the extractGradient function).

Copy link
Author

Choose a reason for hiding this comment

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

If there's a concern, please open a PR that adds new tests. Then I can check if we need to do anything to work with no implicit children.

The changes in this PR are the only changes required to make the current tests pass when working without implicit children. If the implementation relies on children then tests should reflect that.

Copy link
Author

Choose a reason for hiding this comment

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

I just realized that this is not a DT repo.

I'm not sure I understand what the issue is here. If there's more there needs to be done, why does this block this particular PR?

Copy link
Member

Choose a reason for hiding this comment

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

I was just curious why there was a change for this particular component, but if it is for the tests in DT repo, then it makes sense. Could you also point to the test files concerning this change? I think it could be merged, but I think it would be consistent if ReactNode in LinearGradientProps was changed to ReactElement[].

@eps1lon
Copy link
Author

eps1lon commented Mar 5, 2022

Don't actually need this anymore it seems like.

@eps1lon eps1lon closed this Mar 5, 2022
@eps1lon eps1lon deleted the patch-1 branch March 5, 2022 10:46
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.

None yet

3 participants