Skip to content

Commit

Permalink
Remove testID from TextStyle types (#38053)
Browse files Browse the repository at this point in the history
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

Pull Request resolved: #38053

Test Plan:
```tsx
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`.

```tsx
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`.

Reviewed By: javache

Differential Revision: D47006787

Pulled By: NickGerleman

fbshipit-source-id: 6993579ee9c173677594f8f3aea499ac8d8ab232
  • Loading branch information
tobua authored and facebook-github-bot committed Jun 26, 2023
1 parent c5a1f70 commit 3273d38
Showing 1 changed file with 0 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ export interface TextStyle extends TextStyleIOS, TextStyleAndroid, ViewStyle {
textShadowOffset?: {width: number; height: number} | undefined;
textShadowRadius?: number | undefined;
textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase' | undefined;
testID?: string | undefined;
}

/**
Expand Down

0 comments on commit 3273d38

Please sign in to comment.