Files
react-native/Libraries/Types/CodegenTypes.js
T
Rick Hanlon 057ea6a5c7 Add flow parser
Summary:
This diff initializes the codegen flow parser using a proposal for some new syntaxes in flow file to handle missing  information like:

- Float vs Int32
- Bubbling Events vs Direct Events
- Default props
- Codegen options
- Specifying the component name

For a deep dive on the proposal see:  https://fb.quip.com/kPYJAjCHxlgO

Note: there are still some todos to follow up with:
  - Array props
  - Enum props
  - Object event arguments

Note also: the parser code is a little rough, I didn't want spend too much time cleaning it up before we agreed on the format

[General][Added] Add codegen flow parser

Reviewed By: cpojer

Differential Revision: D15417733

fbshipit-source-id: dd80887c0b2ac46fdc3da203214775facd204e28
2019-05-24 09:21:26 -07:00

39 lines
1.1 KiB
JavaScript

/**
* 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';
import type {NativeComponent} from '../Renderer/shims/ReactNative';
import type {SyntheticEvent} from './CoreEventTypes';
// Event types
export type BubblingEvent<T> = SyntheticEvent<T>;
export type DirectEvent<T> = SyntheticEvent<T>;
// Prop types
export type Float = number;
export type Int32 = number;
// Default handling, ignore the unused value
// we're only using it for type checking
//
// TODO: (rickhanlonii) T44881457 If a default is provided, it should always be optional
// 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: number | boolean | string, Value: Type> = Type;
// We're not using ComponentName or Options in JS
// We only use these types to codegen native code
//
// eslint-disable-next-line no-unused-vars
export type CodegenNativeComponent<ComponentName, Props, Options = {}> = Class<
NativeComponent<Props>,
>;