Use more specific enums types where previously using number (#1198)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1198

The Yoga JS bindings converted a previous Flow type directly to TypeScript. The enum types we expose are safer than accepting raw ordinal numbers, and we should replace the places in the typings where an ordinal was accepted instead of the specific type.

Reviewed By: cipolleschi

Differential Revision: D42265824

fbshipit-source-id: 6adcf24a612e79037fdceab0e9f6e4db09fe3ab2
This commit is contained in:
Nick Gerleman
2022-12-30 14:21:08 -08:00
committed by Facebook GitHub Bot
parent cfc3696013
commit 9fe1e77274

View File

@@ -8,17 +8,19 @@
*/ */
import type { import type {
Edge,
Wrap,
Align, Align,
Direction,
Display,
Edge,
ExperimentalFeature,
FlexDirection, FlexDirection,
Gutter, Gutter,
Direction,
PositionType,
Overflow,
Justify, Justify,
Display, MeasureMode,
ExperimentalFeature, Overflow,
PositionType,
Unit,
Wrap,
} from './generated/YGEnums'; } from './generated/YGEnums';
import type * as YGEnums from './generated/YGEnums'; import type * as YGEnums from './generated/YGEnums';
@@ -38,7 +40,7 @@ type Size = {
} }
type Value = { type Value = {
unit: number; unit: Unit;
value: number; value: number;
} }
@@ -53,14 +55,14 @@ export type Config = {
useLegacyStretchBehaviour(): boolean, useLegacyStretchBehaviour(): boolean,
setUseLegacyStretchBehaviour(useLegacyStretchBehaviour: boolean): void, setUseLegacyStretchBehaviour(useLegacyStretchBehaviour: boolean): void,
useWebDefaults(): boolean, useWebDefaults(): boolean,
setUseWebDefaults(useWebDefaults): void, setUseWebDefaults(useWebDefaults: boolean): void,
}; };
export type MeasureFunction = ( export type MeasureFunction = (
width: number, width: number,
widthMode: number, widthMode: MeasureMode,
height: number, height: number,
heightMode: number heightMode: MeasureMode
) => Size; ) => Size;
export type Node = { export type Node = {