From 7f510aabff7296c1fce621db180fedbeac0e8565 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 08:45:16 -0700 Subject: [PATCH 1/8] [React] Remove string index fallback for CSS properties (resolves #24568) --- types/react/index.d.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index b4c350e7d78639..55faaefd3d6667 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -898,11 +898,7 @@ declare namespace React { onTransitionEndCapture?: TransitionEventHandler; } - export interface CSSProperties extends CSS.Properties { - // The string index signature fallback is needed at least until csstype - // provides SVG CSS properties: https://github.com/frenic/csstype/issues/4 - [propertyName: string]: any; - } + export interface CSSProperties extends CSS.Properties {} interface HTMLAttributes extends DOMAttributes { // React-specific Attributes From 8e9416d4e5ec94f4aa9223fc33ba938123dab0b8 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 08:50:00 -0700 Subject: [PATCH 2/8] Require a minimum version of 2.2 for csstype --- types/react/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react/package.json b/types/react/package.json index f3be220fbc2251..e6696d08e7060c 100644 --- a/types/react/package.json +++ b/types/react/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "csstype": "^2.0.0" + "csstype": "^2.2.0" } } From eae12373aaee726d5bfd493a5dbd1cbae7a09b38 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 09:39:47 -0700 Subject: [PATCH 3/8] Fix aphrodite types --- types/aphrodite/index.d.ts | 36 ++++++++++++++++++++++-------------- types/aphrodite/package.json | 6 ++++++ 2 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 types/aphrodite/package.json diff --git a/types/aphrodite/index.d.ts b/types/aphrodite/index.d.ts index 96848955883c23..395f04a25a4448 100644 --- a/types/aphrodite/index.d.ts +++ b/types/aphrodite/index.d.ts @@ -4,27 +4,35 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 -import * as React from "react"; +import * as CSS from "csstype"; + +type BaseCSSProperties = CSS.Properties; type FontFamily = - | React.CSSProperties['fontFamily'] - | Pick + | BaseCSSProperties['fontFamily'] + | CSS.FontFace; + +// Replace with Exclude once on 2.8+ +type Diff = ( + & { [P in T]: P } + & { [P in U]: never } + & { [x: string]: never } +)[T]; + +type CSSProperties = Partial>> & { + fontFamily?: FontFamily | FontFamily[]; +}; + +// For pseudo selectors and media queries +interface OpenCSSProperties extends CSSProperties { + [k: string]: CSSProperties[keyof CSSProperties] | CSSProperties; +} /** * Aphrodite style declaration */ export interface StyleDeclaration { - [key: string]: Pick & { - fontFamily?: FontFamily | FontFamily[]; - }; + [key: string]: OpenCSSProperties; } interface StyleSheetStatic { diff --git a/types/aphrodite/package.json b/types/aphrodite/package.json new file mode 100644 index 00000000000000..e6696d08e7060c --- /dev/null +++ b/types/aphrodite/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "csstype": "^2.2.0" + } +} From 9329111fa83da50ca1f97feddc802befe72e1aab Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 09:45:57 -0700 Subject: [PATCH 4/8] Fix react-confirm test --- types/react-confirm/react-confirm-tests.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-confirm/react-confirm-tests.tsx b/types/react-confirm/react-confirm-tests.tsx index a062b1e2a271f7..cfa3499ffc6de1 100644 --- a/types/react-confirm/react-confirm-tests.tsx +++ b/types/react-confirm/react-confirm-tests.tsx @@ -6,13 +6,13 @@ interface CustomModalProps { } class CustomModal extends React.Component { - modalStyle(): string { - return this.props.show ? "display: none;" : ""; + modalStyle() { + return this.props.show ? { display: 'none' } : undefined; } render() { return ( -
+

{this.props.title}

From fe112430035ae303dd65044c36a2b81ed4a380d0 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 09:51:51 -0700 Subject: [PATCH 5/8] Use Omit --- types/aphrodite/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/aphrodite/index.d.ts b/types/aphrodite/index.d.ts index 395f04a25a4448..583e84e9966f7e 100644 --- a/types/aphrodite/index.d.ts +++ b/types/aphrodite/index.d.ts @@ -18,8 +18,9 @@ type Diff = ( & { [P in U]: never } & { [x: string]: never } )[T]; +type Omit = Pick>; -type CSSProperties = Partial>> & { +type CSSProperties = Omit & { fontFamily?: FontFamily | FontFamily[]; }; From ac455719ce93567446fff7c75eb0a4a404eda011 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 09:52:57 -0700 Subject: [PATCH 6/8] Fix react-geosuggest types --- types/react-geosuggest/index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/react-geosuggest/index.d.ts b/types/react-geosuggest/index.d.ts index 2537754b02a02d..344e768b08a7b0 100644 --- a/types/react-geosuggest/index.d.ts +++ b/types/react-geosuggest/index.d.ts @@ -16,7 +16,15 @@ export default class Geosuggest extends Component { selectSuggest(value?: Suggest): void; } -export interface GeosuggestProps extends InputHTMLAttributes { +// Replace with Exclude once on 2.8+ +export type Diff = ( + & { [P in T]: P } + & { [P in U]: never } + & { [x: string]: never } +)[T]; +export type Omit = Pick>; + +export interface GeosuggestProps extends Omit, 'style'> { placeholder?: string; initialValue?: string; className?: string; From 9aeaaf50532d40e9745021b76d636084cd433e9d Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 09:54:21 -0700 Subject: [PATCH 7/8] Fix victory test --- types/victory/victory-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/victory/victory-tests.tsx b/types/victory/victory-tests.tsx index 56f9d34b542e45..3b882c75839807 100644 --- a/types/victory/victory-tests.tsx +++ b/types/victory/victory-tests.tsx @@ -158,7 +158,7 @@ test = ( grid: {strokeWidth: 2}, ticks: {stroke: "red"}, tickLabels: {fontSize: 12}, - axisLabel: {fontsize: 16} + axisLabel: {fontSize: 16} }} label="Planets" tickValues={[ From 890757016aeb81eee7f5a637450260124c067db3 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 11 Apr 2018 10:21:43 -0700 Subject: [PATCH 8/8] Make customStyle and customStyleOnEditCell into functions --- types/react-bootstrap-table/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-bootstrap-table/index.d.ts b/types/react-bootstrap-table/index.d.ts index 1ad6b3be730f7b..6e9fd1dea8bf18 100644 --- a/types/react-bootstrap-table/index.d.ts +++ b/types/react-bootstrap-table/index.d.ts @@ -1857,7 +1857,7 @@ export interface KeyboardNavigation { /** * Return a style object which will be applied on the navigating cell. */ - customStyle?: CSSProperties; + customStyle?(cell: any, row: any): CSSProperties; /** * Set to false to disable click to navigate, usually user wants to click to select row instead of navigation. */ @@ -1865,7 +1865,7 @@ export interface KeyboardNavigation { /** * Return a style object which will be applied on the both of navigating and editing cell. */ - customStyleOnEditCell?: CSSProperties; + customStyleOnEditCell?(cell: any, row: any): CSSProperties; /** * When set to true, pressing ENTER will begin to edit the cell if cellEdit is also enabled. */