From efbbb0e0c933211135fd8e2a21cf13cd8c258f4f Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Wed, 25 Jan 2017 16:39:20 +0100 Subject: [PATCH] Introduce CSSPercentage type to make CSS properties more explicit --- react/index.d.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index 35a0fce662..6f44d58309 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -611,6 +611,9 @@ declare namespace React { // "all CSS properties can accept these values" type CSSWideKeyword = "initial" | "inherit" | "unset"; + // See CSS 3 type https://drafts.csswg.org/css-values-3/#percentages + type CSSPercentage = string; + // This interface is not complete. Only properties accepting // unitless numbers are listed here (see CSSProperty.js in React) interface CSSProperties { @@ -1150,7 +1153,10 @@ declare namespace React { * Specifies the size of the font. Used to compute em and ex units. * See CSS 3 font-size property https://www.w3.org/TR/css-fonts-3/#propdef-font-size */ - fontSize?: number | string; + fontSize?: ExplicitDefaultingCSSKeywords | + "xx-small" | "x-small" | "small" | "medium" | "large" | "x-large" | "xx-large" | + "larger" | "smaller" | + number | CSSPercentage; /** * The font-size-adjust property adjusts the font-size of the fallback fonts defined with font-family, so that the x-height is the same no matter what font is used. This preserves the readability of the text when fallback happens. @@ -1309,8 +1315,9 @@ declare namespace React { /** * Specifies the height of an inline block level element. + * See CSS 2.1 line-height property https://www.w3.org/TR/CSS21/visudet.html#propdef-line-height */ - lineHeight?: number | string; + lineHeight?: ExplicitDefaultingCSSKeywords | number | CSSPercentage; /** * Shorthand property that sets the list-style-type, list-style-position and list-style-image properties in one declaration. @@ -2004,8 +2011,9 @@ declare namespace React { /** * Sets the initial zoom factor of a document defined by @viewport. + * See CSS zoom descriptor https://drafts.csswg.org/css-device-adapt/#zoom-desc */ - zoom?: "auto" | number; + zoom?: ExplicitDefaultingCSSKeywords | "auto" | number | CSSPercentage; [propertyName: string]: any; }