From 010dc880290789c4bb9819883a26b5e76895db52 Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Sun, 2 Sep 2018 20:53:22 -0700 Subject: [PATCH] Add Flow types to CssStyle. (#1684) --- src/domTree.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/domTree.js b/src/domTree.js index 66e4678a..426d5562 100644 --- a/src/domTree.js +++ b/src/domTree.js @@ -125,7 +125,33 @@ const toMarkup = function(tagName: string): string { return markup; }; -export type CssStyle = {[name: string]: string}; +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. +export type CssStyle = $Shape<{ + backgroundColor: string, + borderBottomWidth: string, + borderColor: string, + borderRightWidth: string, + borderTopWidth: string, + bottom: string, + color: string, + height: string, + left: string, + marginLeft: string, + marginRight: string, + marginTop: string, + minWidth: string, + paddingLeft: string, + position: string, + top: string, + width: string, + verticalAlign: string, +}> & {}; export interface HtmlDomNode extends VirtualNode { classes: string[];