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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3f9f0f3ceb
commit
c09405d58c
2
javascript/src_js/wrapAsm.d.ts
vendored
2
javascript/src_js/wrapAsm.d.ts
vendored
@@ -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,
|
||||
|
Reference in New Issue
Block a user