From deb81853f5618df2ee5fda7096777ac629babb7a Mon Sep 17 00:00:00 2001 From: antliann Date: Tue, 5 Sep 2023 04:57:52 -0700 Subject: [PATCH] Add missing type for TextInput.readOnly in Typescript (#39281) Summary: The `readOnly` prop is available in the `TextInput` implementation (see [usage https://github.com/facebook/react-native/issues/1](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1646), [usage https://github.com/facebook/react-native/issues/2](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1671)), but the corresponding Typescript type is currently missing. Those who use Typescript get an invalid prop error when using the `readOnly` prop on `TextInput`. Having this prop type included in TypeScript would fix the bug above and also would be beneficial for consistency and comprehensive type support. Notably, this prop is also included in the Flow types [here](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js#L814). ## Changelog: [GENERAL] [FIXED] - Add missing type for TextInput.readOnly in Typescript Pull Request resolved: https://github.com/facebook/react-native/pull/39281 Test Plan: N/A Reviewed By: rshest Differential Revision: D48955477 Pulled By: NickGerleman fbshipit-source-id: 9d3431351b8ad65a4d2fc57939b98c167dc70cee --- .../Libraries/Components/TextInput/TextInput.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts index 98922920a2d7dc..2c0c099a894fca 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts @@ -814,6 +814,11 @@ export interface TextInputProps */ placeholderTextColor?: ColorValue | undefined; + /** + * If `true`, text is not editable. The default value is `false`. + */ + readOnly?: boolean | undefined; + /** * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') * Determines how the return key should look.