From 15ed645f34a3ff5ded5aac3bc3cb9284334a9345 Mon Sep 17 00:00:00 2001 From: Zihan Chen Date: Mon, 5 Aug 2019 23:33:11 -0700 Subject: [PATCH] ... --- Note.md | 2 +- ...ponents_failure_COMMANDS_DEFINED_INLINE.ts | 16 +- ...failure_COMMANDS_DEFINED_MULTIPLE_TIMES.ts | 16 +- ...e_COMMANDS_DEFINED_WITHOUT_METHOD_NAMES.ts | 16 +- ...ts_failure_COMMANDS_DEFINED_WITHOUT_REF.ts | 16 +- ...DS_DEFINED_WITH_MISMATCHED_METHOD_NAMES.ts | 16 +- ...lure_COMMANDS_DEFINED_WITH_NULLABLE_REF.ts | 18 +- ...ure_NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE.ts | 16 +- ...omponents_failure_NULLABLE_WITH_DEFAULT.ts | 16 +- ...onents_success_ALL_PROP_TYPES_NO_EVENTS.ts | 90 +-- ...ents_success_ARRAY_PROP_TYPES_NO_EVENTS.ts | 78 +- ...cess_COMMANDS_AND_EVENTS_TYPES_EXPORTED.ts | 88 +-- ...success_COMMANDS_DEFINED_WITH_ALL_TYPES.ts | 16 +- ...ts_success_COMMANDS_WITH_EXTERNAL_TYPES.ts | 16 +- ...s_success_EVENTS_DEFINED_AS_NULL_INLINE.ts | 38 +- ...ss_EVENTS_DEFINED_INLINE_WITH_ALL_TYPES.ts | 686 +++++++++--------- ...ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION.ts | 12 +- ..._OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS.ts | 24 +- ...success_PROPS_AND_EVENTS_TYPES_EXPORTED.ts | 88 +-- ...ponents_success_PROPS_AS_EXTERNAL_TYPES.ts | 11 +- ...LES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT.ts | 5 +- ...ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM.ts | 5 +- ...MODULES_WITH_NOT_EXISTING_TYPE_AS_PARAM.ts | 5 +- ...ODULES_WITH_NOT_EXISTING_TYPE_AS_RETURN.ts | 5 +- ...re_NATIVE_MODULES_WITH_NOT_ONLY_METHODS.ts | 7 +- ...ATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE.ts | 5 +- ...ilure_TWO_NATIVE_EXTENDING_TURBO_MODULE.ts | 9 +- ...WO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT.ts | 5 +- .../modules_success_EMPTY_NATIVE_MODULE.ts | 5 +- ...ess_NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS.ts | 5 +- ...MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE.ts | 5 +- ..._success_NATIVE_MODULE_WITH_BASIC_ARRAY.ts | 5 +- ...ss_NATIVE_MODULE_WITH_BASIC_PARAM_TYPES.ts | 5 +- ...les_success_NATIVE_MODULE_WITH_CALLBACK.ts | 5 +- ...uccess_NATIVE_MODULE_WITH_COMPLEX_ARRAY.ts | 5 +- ...cess_NATIVE_MODULE_WITH_COMPLEX_OBJECTS.ts | 17 +- ..._WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY.ts | 31 +- ...ccess_NATIVE_MODULE_WITH_NULLABLE_PARAM.ts | 7 +- ...WITH_OBJECT_DEIFNED_IN_FILE_AS_PROPERTY.ts | 19 +- ...ules_success_NATIVE_MODULE_WITH_PROMISE.ts | 7 +- ...uccess_NATIVE_MODULE_WITH_SIMPLE_OBJECT.ts | 5 +- ...success_NATIVE_MODULE_WITH_WITH_ALIASES.ts | 7 +- ...NATIVE_MODULE_WITH_WITH_FLOAT_AND_INT32.ts | 7 +- packages/RN-TSCodegen-Test/tslint.json | 7 +- packages/RN-TSCodegen/src/CodegenSchema.ts | 1 - packages/RN-TSCodegen/tslint.json | 9 +- packages/tslint-shared/tslint-export.json | 1 + packages/update-test-files/src/index.ts | 26 +- 48 files changed, 772 insertions(+), 732 deletions(-) diff --git a/Note.md b/Note.md index 762d3e8..4b30720 100644 --- a/Note.md +++ b/Note.md @@ -1,7 +1,7 @@ # Sub module to https://github.com/facebook/react-native - `git submodule add ` -- `git submouule init` +- `git submodule init` - `git submodule update` - `git fetch` / `git merge origin/master` in `react-native` folder diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_INLINE.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_INLINE.ts index b130bd6..f57848c 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_INLINE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_INLINE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,21 +12,20 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEvent, DirectEvent, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands<{ +hotspotUpdate: (ref: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_MULTIPLE_TIMES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_MULTIPLE_TIMES.ts index 33c749f..d418aca 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_MULTIPLE_TIMES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_MULTIPLE_TIMES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,25 +12,24 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEvent, DirectEvent, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; interface NativeCommands { +hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_METHOD_NAMES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_METHOD_NAMES.ts index bb44be7..860ca8d 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_METHOD_NAMES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_METHOD_NAMES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,26 +12,25 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; interface NativeCommands { +hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; +scrollTo: (viewRef: React.Ref<'RCTView'>, y: Int32, animated: boolean) => void; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands(); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_REF.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_REF.ts index 81e8ee3..a9b1922 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_REF.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITHOUT_REF.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,25 +12,24 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEvent, DirectEvent, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; interface NativeCommands { +hotspotUpdate: (x: Int32, y: Int32) => void; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES.ts index 5c358aa..5a952a5 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,26 +12,25 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; interface NativeCommands { +hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; +scrollTo: (viewRef: React.Ref<'RCTView'>, y: Int32, animated: boolean) => void; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['scrollTo'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_NULLABLE_REF.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_NULLABLE_REF.ts index bf62969..a938a79 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_NULLABLE_REF.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_COMMANDS_DEFINED_WITH_NULLABLE_REF.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,25 +12,24 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEvent, DirectEvent, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; interface NativeCommands { - +hotspotUpdate: (viewRef: ?React.Ref<'RCTView'>, x: Int32, y: Int32) => void; + +hotspotUpdate: (viewRef: null | undefined | React.Ref<'RCTView'>, x: Int32, y: Int32) => void; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE.ts index 966e8dc..bd434a3 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,19 +12,18 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { WithDefault, Float, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -export type ModuleProps = $ReadOnly<{| - ...ViewProps, - required_key_with_default: WithDefault, -|}>; +export type ModuleProps = Readonly; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_failure_NULLABLE_WITH_DEFAULT.ts b/packages/RN-TSCodegen-Test/src/inputs/components_failure_NULLABLE_WITH_DEFAULT.ts index 7916ce0..a982b21 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_failure_NULLABLE_WITH_DEFAULT.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_failure_NULLABLE_WITH_DEFAULT.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,19 +12,18 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { WithDefault, Float, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -export type ModuleProps = $ReadOnly<{| - ...ViewProps, - nullable_with_default: ?WithDefault, -|}>; +export type ModuleProps = Readonly; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_ALL_PROP_TYPES_NO_EVENTS.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_ALL_PROP_TYPES_NO_EVENTS.ts index d72bda2..ca6a4d7 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_ALL_PROP_TYPES_NO_EVENTS.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_ALL_PROP_TYPES_NO_EVENTS.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,81 +12,80 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { Int32, Float, WithDefault, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ColorValue, ColorArrayValue, PointValue} from 'StyleSheetTypes'; -import type {ImageSource} from 'ImageSource'; -import type {ViewProps} from 'ViewPropTypes'; +import {ColorValue, ColorArrayValue, PointValue} from '../lib/StyleSheetTypes'; +import {ImageSource} from '../lib/ImageSource'; +import {ViewProps} from '../lib/ViewPropTypes'; -type ModuleProps = $ReadOnly<{| - ...ViewProps, +type ModuleProps = Readonly, - boolean_optional_both?: WithDefault, + boolean_required: boolean; + boolean_optional_key?: WithDefault; + boolean_optional_both?: WithDefault; // String props - string_required: string, - string_optional_key?: WithDefault, - string_optional_both?: WithDefault, + string_required: string; + string_optional_key?: WithDefault; + string_optional_both?: WithDefault; // String props, null default - string_null_optional_key?: WithDefault, - string_null_optional_both?: WithDefault, + string_null_optional_key?: WithDefault; + string_null_optional_both?: WithDefault; // Stringish props - stringish_required: Stringish, - stringish_optional_key?: WithDefault, - stringish_optional_both?: WithDefault, + stringish_required: Stringish; + stringish_optional_key?: WithDefault; + stringish_optional_both?: WithDefault; // Stringish props, null default - stringish_null_optional_key?: WithDefault, - stringish_null_optional_both?: WithDefault, + stringish_null_optional_key?: WithDefault; + stringish_null_optional_both?: WithDefault; // Float props - float_required: Float, - float_optional_key?: WithDefault, - float_optional_both?: WithDefault, + float_required: Float; + float_optional_key?: WithDefault; + float_optional_both?: WithDefault; // Int32 props - int32_required: Int32, - int32_optional_key?: WithDefault, - int32_optional_both?: WithDefault, + int32_required: Int32; + int32_optional_key?: WithDefault; + int32_optional_both?: WithDefault; // String enum props - enum_optional_key?: WithDefault<('small' | 'large'), 'small'>, - enum_optional_both?: WithDefault<('small' | 'large'), 'small'>, + enum_optional_key?: WithDefault<('small' | 'large'), 'small'>; + enum_optional_both?: WithDefault<('small' | 'large'), 'small'>; // ImageSource props - image_required: ImageSource, - image_optional_value: ?ImageSource, - image_optional_both?: ?ImageSource, + image_required: ImageSource; + image_optional_value: null | undefined | ImageSource; + image_optional_both?: null | undefined | ImageSource; // ColorValue props - color_required: ColorValue, - color_optional_key?: ColorValue, - color_optional_value: ?ColorValue, - color_optional_both?: ?ColorValue, + color_required: ColorValue; + color_optional_key?: ColorValue; + color_optional_value: null | undefined | ColorValue; + color_optional_both?: null | undefined | ColorValue; // ColorArrayValue props - color_array_required: ColorArrayValue, - color_array_optional_key?: ColorArrayValue, - color_array_optional_value: ?ColorArrayValue, - color_array_optional_both?: ?ColorArrayValue, + color_array_required: ColorArrayValue; + color_array_optional_key?: ColorArrayValue; + color_array_optional_value: null | undefined | ColorArrayValue; + color_array_optional_both?: null | undefined | ColorArrayValue; // PointValue props - point_required: PointValue, - point_optional_key?: PointValue, - point_optional_value: ?PointValue, - point_optional_both?: ?PointValue, -|}>; + point_required: PointValue; + point_optional_key?: PointValue; + point_optional_value: null | undefined | PointValue; + point_optional_both?: null | undefined | PointValue; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_ARRAY_PROP_TYPES_NO_EVENTS.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_ARRAY_PROP_TYPES_NO_EVENTS.ts index e386896..467f3fa 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_ARRAY_PROP_TYPES_NO_EVENTS.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_ARRAY_PROP_TYPES_NO_EVENTS.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,67 +12,66 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { Int32, Float, WithDefault, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ColorValue, PointValue} from 'StyleSheetTypes'; -import type {ImageSource} from 'ImageSource'; -import type {ViewProps} from 'ViewPropTypes'; +import {ColorValue, PointValue} from '../lib/StyleSheetTypes'; +import {ImageSource} from '../lib/ImageSource'; +import {ViewProps} from '../lib/ViewPropTypes'; -type ModuleProps = $ReadOnly<{| - ...ViewProps, +type ModuleProps = Readonly, - array_boolean_optional_key?: $ReadOnlyArray, - array_boolean_optional_value: ?$ReadOnlyArray, - array_boolean_optional_both?: ?$ReadOnlyArray, + array_boolean_required: ReadonlyArray; + array_boolean_optional_key?: ReadonlyArray; + array_boolean_optional_value: null | undefined | ReadonlyArray; + array_boolean_optional_both?: null | undefined | ReadonlyArray; // String props - array_string_required: $ReadOnlyArray, - array_string_optional_key?: $ReadOnlyArray, - array_string_optional_value: ?$ReadOnlyArray, - array_string_optional_both?: ?$ReadOnlyArray, + array_string_required: ReadonlyArray; + array_string_optional_key?: ReadonlyArray; + array_string_optional_value: null | undefined | ReadonlyArray; + array_string_optional_both?: null | undefined | ReadonlyArray; // Float props - array_float_required: $ReadOnlyArray, - array_float_optional_key?: $ReadOnlyArray, - array_float_optional_value: ?$ReadOnlyArray, - array_float_optional_both?: ?$ReadOnlyArray, + array_float_required: ReadonlyArray; + array_float_optional_key?: ReadonlyArray; + array_float_optional_value: null | undefined | ReadonlyArray; + array_float_optional_both?: null | undefined | ReadonlyArray; // Int32 props - array_int32_required: $ReadOnlyArray, - array_int32_optional_key?: $ReadOnlyArray, - array_int32_optional_value: ?$ReadOnlyArray, - array_int32_optional_both?: ?$ReadOnlyArray, + array_int32_required: ReadonlyArray; + array_int32_optional_key?: ReadonlyArray; + array_int32_optional_value: null | undefined | ReadonlyArray; + array_int32_optional_both?: null | undefined | ReadonlyArray; // String enum props - array_enum_optional_key?: WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, - array_enum_optional_both?: WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, + array_enum_optional_key?: WithDefault, 'small'>; + array_enum_optional_both?: WithDefault, 'small'>; // ImageSource props - array_image_required: $ReadOnlyArray, - array_image_optional_key?: $ReadOnlyArray, - array_image_optional_value: ?$ReadOnlyArray, - array_image_optional_both?: ?$ReadOnlyArray, + array_image_required: ReadonlyArray; + array_image_optional_key?: ReadonlyArray; + array_image_optional_value: null | undefined | ReadonlyArray; + array_image_optional_both?: null | undefined | ReadonlyArray; // ColorValue props - array_color_required: $ReadOnlyArray, - array_color_optional_key?: $ReadOnlyArray, - array_color_optional_value: ?$ReadOnlyArray, - array_color_optional_both?: ?$ReadOnlyArray, + array_color_required: ReadonlyArray; + array_color_optional_key?: ReadonlyArray; + array_color_optional_value: null | undefined | ReadonlyArray; + array_color_optional_both?: null | undefined | ReadonlyArray; // PointValue props - array_point_required: $ReadOnlyArray, - array_point_optional_key?: $ReadOnlyArray, - array_point_optional_value: ?$ReadOnlyArray, - array_point_optional_both?: ?$ReadOnlyArray, -|}>; + array_point_required: ReadonlyArray; + array_point_optional_key?: ReadonlyArray; + array_point_optional_value: null | undefined | ReadonlyArray; + array_point_optional_both?: null | undefined | ReadonlyArray; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_AND_EVENTS_TYPES_EXPORTED.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_AND_EVENTS_TYPES_EXPORTED.ts index f2aa3ce..45becf3 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_AND_EVENTS_TYPES_EXPORTED.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_AND_EVENTS_TYPES_EXPORTED.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,68 +12,68 @@ 'use strict'; -import type { +import { BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -export type EventInFile = $ReadOnly<{| +export type EventInFile = Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } -|}>; +}>; export type Boolean = boolean; export type Int = Int32; @@ -84,17 +85,16 @@ interface NativeCommands { +scrollTo: ScrollTo; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly, - onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler, - onDirectEventDefinedInline: DirectEventHandler, - onDirectEventDefinedInlineWithPaperName: DirectEventHandler, -|}>; + onBubblingEventDefinedInline: BubblingEventHandler; + onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler; + onDirectEventDefinedInline: DirectEventHandler; + onDirectEventDefinedInlineWithPaperName: DirectEventHandler; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['scrollTo'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_DEFINED_WITH_ALL_TYPES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_DEFINED_WITH_ALL_TYPES.ts index f95c1ab..ca7be36 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_DEFINED_WITH_ALL_TYPES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_DEFINED_WITH_ALL_TYPES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,26 +12,25 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; interface NativeCommands { +hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; +scrollTo: (viewRef: React.Ref<'RCTView'>, y: Int32, animated: boolean) => void; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate', 'scrollTo'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_WITH_EXTERNAL_TYPES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_WITH_EXTERNAL_TYPES.ts index 9ac932d..4c2bf0d 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_WITH_EXTERNAL_TYPES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_COMMANDS_WITH_EXTERNAL_TYPES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,16 +12,16 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); -const codegenNativeCommands = require('codegenNativeCommands'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); +import codegenNativeCommands = require('../lib/codegenNativeCommands'); -import type { +import { Int32, BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; export type Boolean = boolean; export type Int = Int32; @@ -32,10 +33,9 @@ interface NativeCommands { +scrollTo: ScrollTo; } -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly; +}>; export const Commands = codegenNativeCommands({ supportedCommands: ['scrollTo'] diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_AS_NULL_INLINE.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_AS_NULL_INLINE.ts index 14f33c8..ef14a49 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_AS_NULL_INLINE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_AS_NULL_INLINE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,42 +12,41 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypese'; +} from '../lib/CodegenTypese'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -type ModuleProps = $ReadOnly<{| - ...ViewProps, +type ModuleProps = Readonly, - onDirectEventDefinedInlineNullOptionalKey?: DirectEventHandler, - onDirectEventDefinedInlineNullOptionalValue: ?DirectEventHandler, - onDirectEventDefinedInlineNullOptionalBoth?: DirectEventHandler, - onDirectEventDefinedInlineNullWithPaperName?: ? + onDirectEventDefinedInlineNullOptionalKey?: DirectEventHandler; + onDirectEventDefinedInlineNullOptionalValue: null | undefined | DirectEventHandler; + onDirectEventDefinedInlineNullOptionalBoth?: DirectEventHandler; + onDirectEventDefinedInlineNullWithPaperName?: null | undefined | DirectEventHandler< - null, + null; 'paperDirectEventDefinedInlineNullWithPaperName', >, - onBubblingEventDefinedInlineNull: BubblingEventHandler, - onBubblingEventDefinedInlineNullOptionalKey?: BubblingEventHandler, - onBubblingEventDefinedInlineNullOptionalValue: ?BubblingEventHandler, - onBubblingEventDefinedInlineNullOptionalBoth?: ?BubblingEventHandler, - onBubblingEventDefinedInlineNullWithPaperName?: ? + onBubblingEventDefinedInlineNull: BubblingEventHandler; + onBubblingEventDefinedInlineNullOptionalKey?: BubblingEventHandler; + onBubblingEventDefinedInlineNullOptionalValue: null | undefined | BubblingEventHandler; + onBubblingEventDefinedInlineNullOptionalBoth?: null | undefined | BubblingEventHandler; + onBubblingEventDefinedInlineNullWithPaperName?: null | undefined | BubblingEventHandler< - null, + null; 'paperBubblingEventDefinedInlineNullWithPaperName', >, -|}>; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_INLINE_WITH_ALL_TYPES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_INLINE_WITH_ALL_TYPES.ts index d753b59..7e812d9 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_INLINE_WITH_ALL_TYPES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_EVENTS_DEFINED_INLINE_WITH_ALL_TYPES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,594 +12,593 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { Int32, Float, BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -type ModuleProps = $ReadOnly<{| - ...ViewProps, +type ModuleProps = Readonly, + }>; >, onDirectEventDefinedInlineOptionalKey?: DirectEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, - onDirectEventDefinedInlineOptionalValue: ? + onDirectEventDefinedInlineOptionalValue: null | undefined | DirectEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, - onDirectEventDefinedInlineOptionalBoth?: ? + onDirectEventDefinedInlineOptionalBoth?: null | undefined | DirectEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, - onDirectEventDefinedInlineWithPaperName?: ? + onDirectEventDefinedInlineWithPaperName?: null | undefined | DirectEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; 'paperDirectEventDefinedInlineWithPaperName', >, onBubblingEventDefinedInline: BubblingEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, onBubblingEventDefinedInlineOptionalKey?: BubblingEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, - onBubblingEventDefinedInlineOptionalValue: ? + onBubblingEventDefinedInlineOptionalValue: null | undefined | BubblingEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, - onBubblingEventDefinedInlineOptionalBoth?: ? + onBubblingEventDefinedInlineOptionalBoth?: null | undefined | BubblingEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; >, - onBubblingEventDefinedInlineWithPaperName?: ? + onBubblingEventDefinedInlineWithPaperName?: null | undefined | BubblingEventHandler< - $ReadOnly<{| + Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } - |}>, + }>; 'paperBubblingEventDefinedInlineWithPaperName' >, -|}>; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION.ts index 07ff953..8b31bff 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,14 +12,13 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -type ModuleProps = $ReadOnly<{| - ...ViewProps, -|}>; +type ModuleProps = Readonly; export default codegenNativeComponent('Module', { - deprecatedViewConfigName: 'DeprecateModuleName', + deprecatedViewConfigName: 'DeprecateModuleName'; }); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS.ts index 72c7644..07e9981 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,28 +12,27 @@ 'use strict'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -import type { +import { BubblingEventHandler, DirectEventHandler, WithDefault, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -type ModuleProps = $ReadOnly<{| - ...ViewProps, +type ModuleProps = Readonly, + boolean_default_true_optional_both?: WithDefault; // Events - onDirectEventDefinedInlineNull: DirectEventHandler, - onBubblingEventDefinedInlineNull: BubblingEventHandler, -|}>; + onDirectEventDefinedInlineNull: DirectEventHandler; + onBubblingEventDefinedInlineNull: BubblingEventHandler; +}>; export default codegenNativeComponent('Module', { - interfaceOnly: true, - paperComponentName: 'RCTModule', + interfaceOnly: true; + paperComponentName: 'RCTModule'; }); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AND_EVENTS_TYPES_EXPORTED.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AND_EVENTS_TYPES_EXPORTED.ts index 794fdcb..93949bb 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AND_EVENTS_TYPES_EXPORTED.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AND_EVENTS_TYPES_EXPORTED.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,79 +12,78 @@ 'use strict'; -import type { +import { BubblingEventHandler, DirectEventHandler, -} from 'CodegenTypes'; +} from '../lib/CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; +import {ViewProps} from '../lib/ViewPropTypes'; -const codegenNativeComponent = require('codegenNativeComponent'); +import codegenNativeComponent = require('../lib/codegenNativeComponent'); -export type EventInFile = $ReadOnly<{| +export type EventInFile = Readonly<{ - boolean_required: boolean, - boolean_optional_key?: boolean, - boolean_optional_value: ?boolean, - boolean_optional_both?: ?boolean, + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: null | undefined | boolean; + boolean_optional_both?: null | undefined | boolean; - string_required: string, - string_optional_key?: string, - string_optional_value: ?string, - string_optional_both?: ?string, + string_required: string; + string_optional_key?: string; + string_optional_value: null | undefined | string; + string_optional_both?: null | undefined | string; - float_required: Float, - float_optional_key?: Float, - float_optional_value: ?Float, - float_optional_both?: ?Float, + float_required: Float; + float_optional_key?: Float; + float_optional_value: null | undefined | Float; + float_optional_both?: null | undefined | Float; - int32_required: Int32, - int32_optional_key?: Int32, - int32_optional_value: ?Int32, - int32_optional_both?: ?Int32, + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: null | undefined | Int32; + int32_optional_both?: null | undefined | Int32; - enum_required: ('small' | 'large'), - enum_optional_key?: ('small' | 'large'), - enum_optional_value: ?('small' | 'large'), - enum_optional_both?: ?('small' | 'large'), + enum_required: ('small' | 'large'); + enum_optional_key?: ('small' | 'large'); + enum_optional_value: null | undefined | ('small' | 'large'); + enum_optional_both?: null | undefined | ('small' | 'large'); object_required: { - boolean_required: boolean, + boolean_required: boolean; } object_optional_key?: { - string_optional_key?: string, + string_optional_key?: string; } - object_optional_value: ?{ - float_optional_value: ?Float, + object_optional_value: null | undefined | { + float_optional_value: null | undefined | Float; } - object_optional_both?: ?{ - int32_optional_both?: ?Int32, + object_optional_both?: null | undefined | { + int32_optional_both?: null | undefined | Int32; } object_required_nested_2_layers: { - object_optional_nested_1_layer?: ?{ - boolean_required: Int32, - string_optional_key?: string, - float_optional_value: ?Float, - int32_optional_both?: ?Int32, + object_optional_nested_1_layer?: null | undefined | { + boolean_required: Int32; + string_optional_key?: string; + float_optional_value: null | undefined | Float; + int32_optional_both?: null | undefined | Int32; } } -|}>; +}>; -export type ModuleProps = $ReadOnly<{| - ...ViewProps, +export type ModuleProps = Readonly, - onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler, - onDirectEventDefinedInline: DirectEventHandler, - onDirectEventDefinedInlineWithPaperName: DirectEventHandler, -|}>; + onBubblingEventDefinedInline: BubblingEventHandler; + onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler; + onDirectEventDefinedInline: DirectEventHandler; + onDirectEventDefinedInlineWithPaperName: DirectEventHandler; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AS_EXTERNAL_TYPES.ts b/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AS_EXTERNAL_TYPES.ts index 56401a8..afdd9ee 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AS_EXTERNAL_TYPES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/components_success_PROPS_AS_EXTERNAL_TYPES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -12,11 +13,11 @@ 'use strict'; export type String = string; -export type AnotherArray = $ReadOnlyArray; +export type AnotherArray = ReadonlyArray; -export type ModuleProps = $ReadOnly<{| - disable: String, - array: AnotherArray, -|}>; +export type ModuleProps = Readonly<{ + disable: String; + array: AnotherArray; +}>; export default codegenNativeComponent('Module'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT.ts index 102a146..06351a1 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { getString: (arg: string) => Array; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM.ts index ad42b4d..1aa7ca5 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { getString: (arg : Array) => string; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_PARAM.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_PARAM.ts index e811b91..bc91a7e 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_PARAM.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_PARAM.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { getString: (arg: NotString) => string; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_RETURN.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_RETURN.ts index e811b91..bc91a7e 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_RETURN.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_EXISTING_TYPE_AS_RETURN.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { getString: (arg: NotString) => string; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_ONLY_METHODS.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_ONLY_METHODS.ts index 5e97532..be1f8a7 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_ONLY_METHODS.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_NOT_ONLY_METHODS.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,14 +12,14 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +getBool: (arg: boolean) => boolean; +getNumber: (arg: number) => number; +getString: (arg: string) => string; - sampleBool: boolean, + sampleBool: boolean; } diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE.ts index 6863afb..63f35a7 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +getBool: (arg: boolean) => Promise; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_EXTENDING_TURBO_MODULE.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_EXTENDING_TURBO_MODULE.ts index e0a5d22..2a7017e 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_EXTENDING_TURBO_MODULE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_EXTENDING_TURBO_MODULE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,15 +12,15 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getSth(a : ?number) => void + +getSth(a : null | undefined | number) => void } export interface Spec2 extends TurboModule { - +getSth(a : ?number) => void + +getSth(a : null | undefined | number) => void } diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT.ts index e8f2bcc..f6e1fbe 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_failure_TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export default TurboModuleRegistry.getEnforcing('SampleTurboModule1'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_EMPTY_NATIVE_MODULE.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_EMPTY_NATIVE_MODULE.ts index e6a25a0..7f6559f 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_EMPTY_NATIVE_MODULE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_EMPTY_NATIVE_MODULE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { // mo methods diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS.ts index 1b0fd4d..de81753 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export type SomeString = string; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE.ts index 47108db..d4cc82f 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +getArray: (arg: Array<[string, string]>) => Array; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_ARRAY.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_ARRAY.ts index a08a039..9fba108 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_ARRAY.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_ARRAY.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +getArray: (arg: Array) => Array; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_PARAM_TYPES.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_PARAM_TYPES.ts index 41f0619..2ba1d5f 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_PARAM_TYPES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_BASIC_PARAM_TYPES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +passBool?: (arg: boolean) => void; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_CALLBACK.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_CALLBACK.ts index 9acc820..07d8fbc 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_CALLBACK.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_CALLBACK.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { // Exported methods. diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_ARRAY.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_ARRAY.ts index 646732e..e9ac9e2 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_ARRAY.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_ARRAY.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +getArray: (arg: Array>>>>) => Array>>; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS.ts index 0131e72..c956f80 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,20 +12,20 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export type String = string export interface Spec extends TurboModule { // Exported methods. - +getObject: (arg: {|const1: {|const1: boolean|}|}) => {| - const1: {|const1: boolean|}, - |}; + +getObject: (arg: {const1: {const1: boolean}}) => { + const1: {const1: boolean}; + }; +getObject2: (arg: { a: String }) => Object; - +getObjectInArray: (arg: {const1: {|const1: boolean|}}) => Array<{| - const1: {const1: boolean}, - |}>; + +getObjectInArray: (arg: {const1: {const1: boolean}}) => Array<{ + const1: {const1: boolean}; + }>; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY.ts index 563c88d..1cca25f 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,23 +12,23 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {| - isTesting: boolean, - reactNativeVersion: {| - major: number, - minor: number, - patch: number, - prerelease: ?number, - |}, - forceTouchAvailable: boolean, - osVersion: string, - systemName: string, - interfaceIdiom: string, - |}; + +getConstants: () => { + isTesting: boolean; + reactNativeVersion: { + major: number; + minor: number; + patch: number; + prerelease: null | undefined | number; + }, + forceTouchAvailable: boolean; + osVersion: string; + systemName: string; + interfaceIdiom: string; + }; } export default TurboModuleRegistry.getEnforcing('PlatformConstants'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_NULLABLE_PARAM.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_NULLABLE_PARAM.ts index 6297720..f35d6d0 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_NULLABLE_PARAM.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_NULLABLE_PARAM.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,12 +12,12 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { // Exported methods. - +voidFunc: (arg: ?string) => void; + +voidFunc: (arg: null | undefined | string) => void; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEIFNED_IN_FILE_AS_PROPERTY.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEIFNED_IN_FILE_AS_PROPERTY.ts index 783b13c..c8bed36 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEIFNED_IN_FILE_AS_PROPERTY.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEIFNED_IN_FILE_AS_PROPERTY.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,19 +12,19 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; -type DisplayMetricsAndroid = {| - width: number, -|}; +type DisplayMetricsAndroid = { + width: number; +}; export interface Spec extends TurboModule { - +getConstants: () => {| - +Dimensions: { - windowPhysicalPixels: DisplayMetricsAndroid, + +getConstants: () => { + Dimensions: { + windowPhysicalPixels: DisplayMetricsAndroid; }, - |}; + }; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_PROMISE.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_PROMISE.ts index 3797cfd..2f9817a 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_PROMISE.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_PROMISE.ts @@ -1,3 +1,4 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -10,11 +11,11 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export type String = string -export type SomeObj = {| a: string |}; +export type SomeObj = { a: string }; export interface Spec extends TurboModule { +getValueWithPromise: () => Promise; diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_SIMPLE_OBJECT.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_SIMPLE_OBJECT.ts index f71f0d5..0959083 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_SIMPLE_OBJECT.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_SIMPLE_OBJECT.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; export interface Spec extends TurboModule { +getObject(o : Object) => Object, diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_ALIASES.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_ALIASES.ts index b6cefb8..764101a 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_ALIASES.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_ALIASES.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,8 +12,8 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; type NumNum = number; export type Num = (arg: NumNum) => void; @@ -25,7 +26,7 @@ export interface Spec extends TurboModule { // Exported methods. +getNumber: Num2; +getVoid: () => Void; - +getArray: (a : Array) => {| a: B |}; + +getArray: (a : Array) => { a: B }; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_FLOAT_AND_INT32.ts b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_FLOAT_AND_INT32.ts index b965584..5dda4ff 100644 --- a/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_FLOAT_AND_INT32.ts +++ b/packages/RN-TSCodegen-Test/src/inputs/modules_success_NATIVE_MODULE_WITH_WITH_FLOAT_AND_INT32.ts @@ -1,4 +1,5 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * @@ -11,9 +12,9 @@ 'use strict'; -import type {TurboModule} from '../RCTExport'; -import * as TurboModuleRegistry from '../TurboModuleRegistry'; -import type {Int32, Float} from 'react-native/Libraries/Types/CodegenTypes'; +import {TurboModule} from '../lib/RCTExport'; +import * as TurboModuleRegistry from '../lib/TurboModuleRegistry'; +import {Int32, Float} from '../lib/react-native/Libraries/Types/CodegenTypes'; export interface Spec extends TurboModule { +getInt: (arg: Int32) => Int32; diff --git a/packages/RN-TSCodegen-Test/tslint.json b/packages/RN-TSCodegen-Test/tslint.json index e6b09f1..2fd5fb2 100644 --- a/packages/RN-TSCodegen-Test/tslint.json +++ b/packages/RN-TSCodegen-Test/tslint.json @@ -1,5 +1,10 @@ { "extends": [ "tslint-shared" - ] + ], + "linterOptions": { + "exclude": [ + "src/inputs/*.ts" + ] + } } diff --git a/packages/RN-TSCodegen/src/CodegenSchema.ts b/packages/RN-TSCodegen/src/CodegenSchema.ts index aa6f29d..2c4150a 100644 --- a/packages/RN-TSCodegen/src/CodegenSchema.ts +++ b/packages/RN-TSCodegen/src/CodegenSchema.ts @@ -1,5 +1,4 @@ -// tslint:disable:no-reserved-keywords /** * Copyright (c) Facebook, Inc. and its affiliates. * diff --git a/packages/RN-TSCodegen/tslint.json b/packages/RN-TSCodegen/tslint.json index e6b09f1..7ff6b45 100644 --- a/packages/RN-TSCodegen/tslint.json +++ b/packages/RN-TSCodegen/tslint.json @@ -1,5 +1,10 @@ { "extends": [ "tslint-shared" - ] -} + ], + "linterOptions": { + "exclude": [ + "src/CodegenSchema.ts" + ] + } +} \ No newline at end of file diff --git a/packages/tslint-shared/tslint-export.json b/packages/tslint-shared/tslint-export.json index c5c589e..f9301f3 100644 --- a/packages/tslint-shared/tslint-export.json +++ b/packages/tslint-shared/tslint-export.json @@ -3,6 +3,7 @@ "tslint-microsoft-contrib" ], "rules": { + "interface-name": false, "linebreak-style": false, "newline-per-chained-call": false, "no-console": [ diff --git a/packages/update-test-files/src/index.ts b/packages/update-test-files/src/index.ts index b48029d..f72df36 100644 --- a/packages/update-test-files/src/index.ts +++ b/packages/update-test-files/src/index.ts @@ -1,18 +1,23 @@ +// tslint:disable:max-line-length + import * as fs from 'fs'; import * as path from 'path'; function flowToTs(flowSourceCode: string): string { return ` -// tslint:disable:no-reserved-keywords ${flowSourceCode - .replace(/\$ReadOnly -> Readonly - .replace(/\$ReadOnlyArray -> ReadonlyArray - .replace(/\{\|/g, `{`) // {| ... |} -> { ... } - .replace(/\|\}/g, `}`) - .replace(/: \?/g, `: null | undefined | `) // ?T -> null | undefined | T - .replace(/([a-zA-Z_0-9$]+\??): ([^,]+),/g, '$1: $2;') // {a,b,c} -> {a; b; c;} - .replace(/\}>,/g, `}>;`) - .replace(/\{(\s+)\.\.\.(\w+),/g, '$2 & {') // {...a, b; c;} -> a & {b; c;} + .replace(/\$ReadOnly -> Readonly + .replace(/\$ReadOnlyArray -> ReadonlyArray + .replace(/\{\|/g, `{`) // {| ... |} -> { ... } + .replace(/\|\}/g, `}`) // + .replace(/: \?/g, `: null | undefined | `) // ?T -> null | undefined | T + .replace(/\+?([a-zA-Z_0-9$]+\??): ([^=]*?),$/gm, '$1: $2;') // {+a,b,c} -> {a; b; c;} + .replace(/\}>,/g, `}>;`) // + //.replace(/^(\s*)\+(\w+):/gm, '$1$2:') // {+a:b;} -> {a:b;} + .replace(/\{(\s+)\.\.\.(\w+),/g, '$2 & {') // {...a, b; c;} -> a & {b; c;} + .replace(/const (\w+) = require\('(\.\.\/)?([^']+)'\);/g, `import $1 = require('../lib/$3');`) // const NAME = require('MODULE'); -> import NAME = require('../lib/MODULE'); + .replace(/import type \{/g, 'import {') // import type {x} from 'MODULE'; -> import {x} from '../lib/MODULE'; + .replace(/from '(\.\.\/)?([^']+)';/g, `from '../lib/$2';`) // }`; } @@ -35,7 +40,8 @@ function convertTestInput(inputJsPath: string, outputFolder: string, prefix: str Object.keys(testCases).forEach((key: string) => { const outputPath = path.join(outputFolder, `${prefix}${key}.ts`); const flowSourceCode = testCases[key]; - fs.writeFileSync(outputPath, flowSourceCode, { encoding: 'utf-8' }); + const tsSourceCode = flowToTs(flowSourceCode); + fs.writeFileSync(outputPath, tsSourceCode, { encoding: 'utf-8' }); }); return testCases;