From c09405d58c624fd26d5e0a7ed98bd10c5cc4c05b Mon Sep 17 00:00:00 2001 From: Bela Bohlender Date: Wed, 1 Mar 2023 07:40:03 -0800 Subject: [PATCH] Typescript: improve enum types and setMargin type (#1233) Summary: Currently, it is impossible to write `node.setPositionType(2)` instead of `node.setPositionType(POSITION_TYPE_ABSOLUTE)`. I understand that the idea is to force explicit usage of the enums. However, declaring `type POSITION_TYPE_ABSOLUTE = 2 & ['POSITION_TYPE']` artificially limits use cases, where, for example, the state should be serialized typesafe. Additionally, this PR fixes the incorrect typing of `setMargin(edge: Edge, margin: number)` by extending the type to `margin: number | string` Pull Request resolved: https://github.com/facebook/yoga/pull/1233 Reviewed By: javache Differential Revision: D43695520 Pulled By: NickGerleman fbshipit-source-id: aac5f1de71817cc268fb003454ba29d31be10e0b --- javascript/src_js/wrapAsm.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/src_js/wrapAsm.d.ts b/javascript/src_js/wrapAsm.d.ts index a847e4a8..b65795a9 100644 --- a/javascript/src_js/wrapAsm.d.ts +++ b/javascript/src_js/wrapAsm.d.ts @@ -135,7 +135,7 @@ export type Node = { setHeightPercent(height: number): void, setJustifyContent(justifyContent: Justify): void, setGap(gutter: Gutter, gapLength: number): Value, - setMargin(edge: Edge, margin: number): void, + setMargin(edge: Edge, margin: number | string): void, setMarginAuto(edge: Edge): void, setMarginPercent(edge: Edge, margin: number): void, setMaxHeight(maxHeight: number | string): void,