From 61e95e5cbf550d446a0bc2e656a603d5bce19563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Osadnik?= Date: Tue, 2 Jul 2019 02:59:04 -0700 Subject: [PATCH] Force WithDefault not to be an optional value Summary: `WithDefault` appears not to be required to be prefixed with `?` because it's option value per se. Fixed tests, removed `?` where needed, updated snapshots and review them. Added mechanism fro throwing error when `?WithDefault` found. Add tests for it. Reviewed By: rubennorte Differential Revision: D16048463 fbshipit-source-id: f55ed7454aacf0b8c42944a9b5c1037ad1b360fe --- .../ActivityIndicatorViewNativeComponent.js | 6 +-- .../AndroidDialogPickerNativeComponent.js | 4 +- .../AndroidDropdownPickerNativeComponent.js | 4 +- .../ProgressBarAndroidNativeComponent.js | 4 +- .../RCTProgressViewNativeComponent.js | 4 +- ...ndroidSwipeRefreshLayoutNativeComponent.js | 8 ++-- .../PullToRefreshViewNativeComponent.js | 2 +- .../RCTSegmentedControlNativeComponent.js | 6 +-- .../Slider/SliderNativeComponent.js | 14 +++---- .../Switch/SwitchNativeComponent.js | 4 +- .../UnimplementedNativeViewNativeComponent.js | 2 +- .../Modal/RCTModalHostViewNativeComponent.js | 16 ++++---- Libraries/Types/CodegenTypes.js | 2 +- .../__test_fixtures__/fixtures.js | 2 +- .../__snapshots__/index-test.js.snap | 2 +- .../flow/__test_fixtures__/failures.js | 31 ++++++++++++++ .../flow/__test_fixtures__/fixtures.js | 40 +++++++++---------- .../__snapshots__/parser-test.js.snap | 37 +---------------- .../src/parsers/flow/props.js | 23 ++++++++--- 19 files changed, 110 insertions(+), 101 deletions(-) diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js b/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js index 9cdb6f027e4..47c8fa1692a 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js @@ -25,14 +25,14 @@ type NativeProps = $ReadOnly<{| * * See http://facebook.github.io/react-native/docs/activityindicator.html#hideswhenstopped */ - hidesWhenStopped?: ?WithDefault, + hidesWhenStopped?: WithDefault, /** * Whether to show the indicator (true, the default) or hide it (false). * * See http://facebook.github.io/react-native/docs/activityindicator.html#animating */ - animating?: ?WithDefault, + animating?: WithDefault, /** * The foreground color of the spinner (default is gray). @@ -47,7 +47,7 @@ type NativeProps = $ReadOnly<{| * * See http://facebook.github.io/react-native/docs/activityindicator.html#size */ - size?: ?WithDefault<'small' | 'large', 'small'>, + size?: WithDefault<'small' | 'large', 'small'>, |}>; export default codegenNativeComponent('ActivityIndicatorView', { diff --git a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js index 77444816ef3..dd5f5a10912 100644 --- a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js @@ -37,9 +37,9 @@ type NativeProps = $ReadOnly<{| // Props color?: ?ColorValue, - enabled?: ?WithDefault, + enabled?: WithDefault, items: $ReadOnlyArray, - prompt?: ?WithDefault, + prompt?: WithDefault, selected: Int32, // Events diff --git a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js index 2b0e1773ef2..8f3976b4a66 100644 --- a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js @@ -37,9 +37,9 @@ type NativeProps = $ReadOnly<{| // Props color?: ?ColorValue, - enabled?: ?WithDefault, + enabled?: WithDefault, items: $ReadOnlyArray, - prompt?: ?WithDefault, + prompt?: WithDefault, selected: Int32, // Events diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js index fffa7c3f2c6..47af65b9f13 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js @@ -24,9 +24,9 @@ type NativeProps = $ReadOnly<{| typeAttr?: string, indeterminate: boolean, progress?: WithDefault, - animating?: ?WithDefault, + animating?: WithDefault, color?: ?ColorValue, - testID?: ?WithDefault, + testID?: WithDefault, |}>; export default codegenNativeComponent('AndroidProgressBar'); diff --git a/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js b/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js index 3a9e4b138e0..ba8427354cb 100644 --- a/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +++ b/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js @@ -21,8 +21,8 @@ type NativeProps = $ReadOnly<{| ...ViewProps, // Props - progressViewStyle?: ?WithDefault<'default' | 'bar', 'default'>, - progress?: ?WithDefault, + progressViewStyle?: WithDefault<'default' | 'bar', 'default'>, + progress?: WithDefault, progressTintColor?: ?ColorValue, trackTintColor?: ?ColorValue, progressImage?: ?ImageSource, diff --git a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js index 9e8f0ea583b..4109dae7f82 100644 --- a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +++ b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js @@ -27,7 +27,7 @@ type NativeProps = $ReadOnly<{| /** * Whether the pull to refresh functionality is enabled. */ - enabled?: ?WithDefault, + enabled?: WithDefault, /** * The colors (at least one) that will be used to draw the refresh indicator. */ @@ -45,13 +45,13 @@ type NativeProps = $ReadOnly<{| * Also, 1 isn't actually a safe default. We are able to set this here * because native code isn't currently consuming the generated artifact. * This will end up being - * size?: ?WithDefault<'default' | 'large', 'default'>, + * size?: WithDefault<'default' | 'large', 'default'>, */ - size?: ?WithDefault, + size?: WithDefault, /** * Progress view top offset */ - progressViewOffset?: ?WithDefault, + progressViewOffset?: WithDefault, /** * Called when the view starts refreshing. diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index a38f28b4695..87851403fa2 100644 --- a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -30,7 +30,7 @@ type NativeProps = $ReadOnly<{| /** * The title displayed under the refresh indicator. */ - title?: ?WithDefault, + title?: WithDefault, /** * Called when the view starts refreshing. diff --git a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js index 9105deddd2a..b21f7148824 100644 --- a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +++ b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js @@ -28,10 +28,10 @@ type NativeProps = $ReadOnly<{| // Props values?: $ReadOnlyArray, - selectedIndex?: ?WithDefault, - enabled?: ?WithDefault, + selectedIndex?: WithDefault, + enabled?: WithDefault, tintColor?: ?ColorValue, - momentary?: ?WithDefault, + momentary?: WithDefault, // Events onChange?: ?BubblingEventHandler, diff --git a/Libraries/Components/Slider/SliderNativeComponent.js b/Libraries/Components/Slider/SliderNativeComponent.js index 9b809e1ca65..f6475bbd882 100644 --- a/Libraries/Components/Slider/SliderNativeComponent.js +++ b/Libraries/Components/Slider/SliderNativeComponent.js @@ -32,20 +32,20 @@ type NativeProps = $ReadOnly<{| ...ViewProps, // Props - disabled?: ?WithDefault, - enabled?: ?WithDefault, + disabled?: WithDefault, + enabled?: WithDefault, maximumTrackImage?: ?ImageSource, maximumTrackTintColor?: ?ColorValue, - maximumValue?: ?WithDefault, + maximumValue?: WithDefault, minimumTrackImage?: ?ImageSource, minimumTrackTintColor?: ?ColorValue, - minimumValue?: ?WithDefault, - step?: ?WithDefault, - testID?: ?WithDefault, + minimumValue?: WithDefault, + step?: WithDefault, + testID?: WithDefault, thumbImage?: ?ImageSource, thumbTintColor?: ?ColorValue, trackImage?: ?ImageSource, - value: ?WithDefault, + value: WithDefault, // Events onChange?: ?BubblingEventHandler, diff --git a/Libraries/Components/Switch/SwitchNativeComponent.js b/Libraries/Components/Switch/SwitchNativeComponent.js index ea223bbde5e..1315d2addbd 100644 --- a/Libraries/Components/Switch/SwitchNativeComponent.js +++ b/Libraries/Components/Switch/SwitchNativeComponent.js @@ -24,8 +24,8 @@ type NativeProps = $ReadOnly<{| ...ViewProps, // Props - disabled?: ?WithDefault, - value?: ?WithDefault, + disabled?: WithDefault, + value?: WithDefault, tintColor?: ?ColorValue, onTintColor?: ?ColorValue, thumbTintColor?: ?ColorValue, diff --git a/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js b/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js index 353a3102d96..ed0622ab428 100644 --- a/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +++ b/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js @@ -17,7 +17,7 @@ import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; type NativeProps = $ReadOnly<{| ...ViewProps, - name?: ?WithDefault, + name?: WithDefault, |}>; // NOTE: This compoenent is not implemented in paper diff --git a/Libraries/Modal/RCTModalHostViewNativeComponent.js b/Libraries/Modal/RCTModalHostViewNativeComponent.js index 1e305442d35..b8e8f06e9b3 100644 --- a/Libraries/Modal/RCTModalHostViewNativeComponent.js +++ b/Libraries/Modal/RCTModalHostViewNativeComponent.js @@ -32,14 +32,14 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#animationtype */ - animationType?: ?WithDefault<'none' | 'slide' | 'fade', 'none'>, + animationType?: WithDefault<'none' | 'slide' | 'fade', 'none'>, /** * The `presentationStyle` prop controls how the modal appears. * * See https://facebook.github.io/react-native/docs/modal.html#presentationstyle */ - presentationStyle?: ?WithDefault< + presentationStyle?: WithDefault< 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen', 'fullScreen', >, @@ -50,7 +50,7 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#transparent */ - transparent?: ?WithDefault, + transparent?: WithDefault, /** * The `hardwareAccelerated` prop controls whether to force hardware @@ -58,14 +58,14 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#hardwareaccelerated */ - hardwareAccelerated?: ?WithDefault, + hardwareAccelerated?: WithDefault, /** * The `visible` prop determines whether your modal is visible. * * See https://facebook.github.io/react-native/docs/modal.html#visible */ - visible?: ?WithDefault, + visible?: WithDefault, /** * The `onRequestClose` callback is called when the user taps the hardware @@ -96,14 +96,14 @@ type NativeProps = $ReadOnly<{| /** * Deprecated. Use the `animationType` prop instead. */ - animated?: ?WithDefault, + animated?: WithDefault, /** * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations. * * See https://facebook.github.io/react-native/docs/modal.html#supportedorientations */ - supportedOrientations?: ?WithDefault< + supportedOrientations?: WithDefault< $ReadOnlyArray< | 'portrait' | 'portrait-upside-down' @@ -124,7 +124,7 @@ type NativeProps = $ReadOnly<{| /** * The `identifier` is the unique number for identifying Modal components. */ - identifier?: ?WithDefault, + identifier?: WithDefault, |}>; export default codegenNativeComponent('ModalHostView', { diff --git a/Libraries/Types/CodegenTypes.js b/Libraries/Types/CodegenTypes.js index 8a385d850f8..0ef355ddbd6 100644 --- a/Libraries/Types/CodegenTypes.js +++ b/Libraries/Types/CodegenTypes.js @@ -36,4 +36,4 @@ type DefaultTypes = number | boolean | string | $ReadOnlyArray; // but that is currently not supported in the codegen since we require a default // // eslint-disable-next-line no-unused-vars -export type WithDefault = Type; +export type WithDefault = ?Type; diff --git a/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js b/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js index d4ad955d4d0..c40d4ed27f7 100644 --- a/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js +++ b/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js @@ -39,7 +39,7 @@ type ModuleProps = $ReadOnly<{| ...ViewProps, // Props - boolean_default_true_optional_both?: ?WithDefault, + boolean_default_true_optional_both?: WithDefault, // Events onDirectEventDefinedInlineNull: DirectEventHandler, diff --git a/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap index 1e29afabb80..9d203135ccd 100644 --- a/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap @@ -14,7 +14,7 @@ interface NativeCommands { } type ModuleProps = $ReadOnly<{| ...ViewProps, // Props - boolean_default_true_optional_both?: ?WithDefault, + boolean_default_true_optional_both?: WithDefault, // Events onDirectEventDefinedInlineNull: DirectEventHandler, onBubblingEventDefinedInlineNull: BubblingEventHandler, diff --git a/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/failures.js b/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/failures.js index 19907602b12..88681a062d5 100644 --- a/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/failures.js +++ b/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/failures.js @@ -120,6 +120,36 @@ export type ModuleProps = $ReadOnly<{| export const Commands = codegenNativeCommands(); +export default codegenNativeComponent('Module'); +`; +const NULLABLE_WITH_DEFAULT = ` +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type { + WithDefault, + Float, +} from 'CodegenTypes'; + +import type {ViewProps} from 'ViewPropTypes'; + + +export type ModuleProps = $ReadOnly<{| + ...ViewProps, + nullable_with_default: ?WithDefault, +|}>; + export default codegenNativeComponent('Module'); `; @@ -127,4 +157,5 @@ module.exports = { COMMANDS_DEFINED_INLINE, COMMANDS_DEFINED_MULTIPLE_TIMES, COMMANDS_DEFINED_WITHOUT_REF, + NULLABLE_WITH_DEFAULT, }; diff --git a/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js index de6e81d7d7b..617f7039fdc 100644 --- a/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js @@ -89,7 +89,7 @@ type ModuleProps = $ReadOnly<{| ...ViewProps, // Props - boolean_default_true_optional_both?: ?WithDefault, + boolean_default_true_optional_both?: WithDefault, // Events onDirectEventDefinedInlineNull: DirectEventHandler, @@ -160,48 +160,47 @@ type ModuleProps = $ReadOnly<{| // Boolean props boolean_required: boolean, boolean_optional_key?: WithDefault, - boolean_optional_value: ?WithDefault, - boolean_optional_both?: ?WithDefault, + boolean_optional_value: WithDefault, + boolean_optional_both?: WithDefault, // String props string_required: string, string_optional_key?: WithDefault, - string_optional_value: ?WithDefault, - string_optional_both?: ?WithDefault, + string_optional_value: WithDefault, + string_optional_both?: WithDefault, // String props, null default string_null_optional_key?: WithDefault, - string_null_optional_value: ?WithDefault, - string_null_optional_both?: ?WithDefault, + string_null_optional_value: WithDefault, + string_null_optional_both?: WithDefault, // Stringish props stringish_required: Stringish, stringish_optional_key?: WithDefault, - stringish_optional_value: ?WithDefault, - stringish_optional_both?: ?WithDefault, + stringish_optional_value: WithDefault, + stringish_optional_both?: WithDefault, // Stringish props, null default stringish_null_optional_key?: WithDefault, - stringish_null_optional_value: ?WithDefault, - stringish_null_optional_both?: ?WithDefault, + stringish_null_optional_value: WithDefault, + stringish_null_optional_both?: WithDefault, // Float props float_required: Float, float_optional_key?: WithDefault, - float_optional_value: ?WithDefault, - float_optional_both?: ?WithDefault, + float_optional_value: WithDefault, + float_optional_both?: WithDefault, // Int32 props int32_required: Int32, int32_optional_key?: WithDefault, - int32_optional_value: ?WithDefault, - int32_optional_both?: ?WithDefault, + int32_optional_value: WithDefault, + int32_optional_both?: WithDefault, // String enum props - enum_required: WithDefault<('small' | 'large'), 'small'>, enum_optional_key?: WithDefault<('small' | 'large'), 'small'>, - enum_optional_value: ?WithDefault<('small' | 'large'), 'small'>, - enum_optional_both?: ?WithDefault<('small' | 'large'), 'small'>, + enum_optional_value: WithDefault<('small' | 'large'), 'small'>, + enum_optional_both?: WithDefault<('small' | 'large'), 'small'>, // ImageSource props image_required: ImageSource, @@ -284,10 +283,9 @@ type ModuleProps = $ReadOnly<{| array_int32_optional_both?: ?$ReadOnlyArray, // String enum props - array_enum_required: WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, array_enum_optional_key?: WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, - array_enum_optional_value: ?WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, - array_enum_optional_both?: ?WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, + array_enum_optional_value: WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, + array_enum_optional_both?: WithDefault<$ReadOnlyArray<('small' | 'large')>, 'small'>, // ImageSource props array_image_required: $ReadOnlyArray, diff --git a/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap index db03605d833..2171259177a 100644 --- a/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap @@ -6,6 +6,8 @@ exports[`RN Codegen Flow Parser Fails with error message COMMANDS_DEFINED_MULTIP exports[`RN Codegen Flow Parser Fails with error message COMMANDS_DEFINED_WITHOUT_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.Ref<>"`; +exports[`RN Codegen Flow Parser Fails with error message NULLABLE_WITH_DEFAULT 1`] = `"WithDefault<> is optional and does not need to be marked as optional. Please remove the ? annotation in front of it."`; + exports[`RN Codegen Flow Parser can generate fixture ALL_PROP_TYPES_NO_EVENTS 1`] = ` Object { "modules": Object { @@ -229,22 +231,6 @@ Object { "type": "Int32TypeAnnotation", }, }, - Object { - "name": "enum_required", - "optional": false, - "typeAnnotation": Object { - "default": "small", - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - }, Object { "name": "enum_optional_key", "optional": true, @@ -608,25 +594,6 @@ Object { "type": "ArrayTypeAnnotation", }, }, - Object { - "name": "array_enum_required", - "optional": false, - "typeAnnotation": Object { - "elementType": Object { - "default": "small", - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - "type": "ArrayTypeAnnotation", - }, - }, Object { "name": "array_enum_optional_key", "optional": true, diff --git a/packages/react-native-codegen/src/parsers/flow/props.js b/packages/react-native-codegen/src/parsers/flow/props.js index b07c444777a..9d7907ddf8d 100644 --- a/packages/react-native-codegen/src/parsers/flow/props.js +++ b/packages/react-native-codegen/src/parsers/flow/props.js @@ -176,13 +176,26 @@ function getTypeAnnotation(name, typeAnnotation, defaultValue) { function buildPropSchema(property): ?PropTypeShape { const name = property.key.name; - const optional = - property.value.type === 'NullableTypeAnnotation' || property.optional; + const {value} = property; let typeAnnotation = - property.value.type === 'NullableTypeAnnotation' - ? property.value.typeAnnotation - : property.value; + value.type === 'NullableTypeAnnotation' ? value.typeAnnotation : value; + + const optional = + value.type === 'NullableTypeAnnotation' || + property.optional || + (value.type === 'GenericTypeAnnotation' && + typeAnnotation.id.name === 'WithDefault'); + + if ( + value.type === 'NullableTypeAnnotation' && + (typeAnnotation.type === 'GenericTypeAnnotation' && + typeAnnotation.id.name === 'WithDefault') + ) { + throw new Error( + 'WithDefault<> is optional and does not need to be marked as optional. Please remove the ? annotation in front of it.', + ); + } let type = typeAnnotation.type; if (