Skip to content

Commit 9ecd203

Browse files
ZihanChen-MSFTfacebook-github-bot
authored andcommitted
Accept TypeScript type T | null | undefined as a maybe type of T in turbo module (#34158)
Summary: According Flow's document, a maybe type of T means `T | null | undefined`, instead of `T | null | void`. I think keeping TypeScript and Flow being consistent to each other is better. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Changed] - Accept TypeScript type `T | null | undefined` as a maybe type of T in turbo module. Pull Request resolved: #34158 Test Plan: `yarn jest` passed in `packages/react-native-codegen` Reviewed By: yungsters Differential Revision: D37731169 Pulled By: philIip fbshipit-source-id: b6d9b7e8991f60e12c1004bed5b937b34fb02c47
1 parent bf54f1c commit 9ecd203

File tree

7 files changed

+109
-108
lines changed

7 files changed

+109
-108
lines changed

packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/failures.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ import type {ViewProps} from 'ViewPropTypes';
141141
import type {HostComponent} from 'react-native';
142142
143143
interface NativeCommands {
144-
readonly hotspotUpdate: (viewRef: React.Ref<'RCTView'> | null | void, x: Int32, y: Int32) => void;
144+
readonly hotspotUpdate: (viewRef: React.Ref<'RCTView'> | null | undefined, x: Int32, y: Int32) => void;
145145
}
146146
147147
export interface ModuleProps extends ViewProps {
@@ -249,7 +249,7 @@ import type {ViewProps} from 'ViewPropTypes';
249249
import type {HostComponent} from 'react-native';
250250
251251
export interface ModuleProps extends ViewProps {
252-
nullable_with_default: WithDefault<Float, 1.0> | null | void;
252+
nullable_with_default: WithDefault<Float, 1.0> | null | undefined;
253253
}
254254
255255
export default codegenNativeComponent<ModuleProps>(

0 commit comments

Comments
 (0)