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

Remove testID from TextStyle types #38053

Closed
wants to merge 1 commit into from

Conversation

tobua
Copy link
Contributor

@tobua tobua commented Jun 25, 2023

Summary:

testID which is a valid prop for <Text> is also found in the types for TextStyle. This pull request removes said property from the styles.

Changelog:

[General] [Fixed] - Remove testID from TextStyle types

Test Plan:

const styles = StyleSheet.create({
  view: {
    testID: 'should-error-in-typescript-but-does-not'
  }
})

TextStyle is used to type the StyleSheet along with ViewStyle and ImageStyle which do not contain testID.

const MyText = <Text testID="already-typed-fine">Hello</Text>

testID is used to identify components with the mentioned prop. This works for Text and will continue to do so, TextProps has testID added specifically. When using getByTestId in jest adding testID to the style already has no effect.

When adding testID to a style a warning will already be shown in development: Warning: Failed prop type: Invalid props.style key testID supplied to Text.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 25, 2023
Copy link
Contributor

@NickGerleman NickGerleman left a comment

Choose a reason for hiding this comment

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

LGTM

@facebook-github-bot
Copy link
Contributor

@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Pranav-yadav
Copy link
Contributor

@tobua Danger check failed, change the "Changelog" in PR descriptions as suggested here: #38053 (comment)

@tobua
Copy link
Contributor Author

tobua commented Jun 26, 2023

@tobua Danger check failed, change the "Changelog" in PR descriptions as suggested here: #38053 (comment)

@Pranav-yadav Fixed, wasn't able to edit the post before, thanks!

@github-actions
Copy link

This pull request was successfully merged by @tobua in 3273d38.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions bot added the Merged This PR has been merged. label Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants