From a3dd726ba33d460a539488394e2b286b0dea9669 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Feb 2017 17:05:14 -0800 Subject: [PATCH 1/3] Revert "Fix #11566 allows SFC to return null" This reverts commit 81730dfd225b778bfd0f0a7e1524899a372ad37c. --- react/index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index f25e5c0afd..e39c8c7026 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -204,7 +204,7 @@ declare namespace React { type SFC

= StatelessComponent

; interface StatelessComponent

{ - (props: P & { children?: ReactNode }, context?: any): ReactElement | null; + (props: P & { children?: ReactNode }, context?: any): ReactElement; propTypes?: ValidationMap

; contextTypes?: ValidationMap; defaultProps?: P; @@ -2628,9 +2628,7 @@ declare namespace React { declare global { namespace JSX { - interface JSXElement extends React.ReactElement { } - type Element = JSXElement | null; - + interface Element extends React.ReactElement { } interface ElementClass extends React.Component { render(): JSX.Element; } From 47f5a06ab00097373ee387f9b5ebad6d90d9cae9 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Feb 2017 17:05:24 -0800 Subject: [PATCH 2/3] Revert "Add tests and fix broken test" This reverts commit d79f340d574873ca4deabd545ee4b9fdab1164ec. --- react-day-picker/index.d.ts | 2 +- react-dom/index.d.ts | 4 ++-- react-input-mask/index.d.ts | 2 +- react-native-scrollable-tab-view/index.d.ts | 18 +++++++++--------- .../react-native-swiper-tests.tsx | 2 +- react/index.d.ts | 4 ++-- react/test/tsx.tsx | 3 --- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index f2993d95c5..01c5492922 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -75,7 +75,7 @@ declare namespace ReactDayPicker { toMonth?: Date; localeUtils?: LocaleUtils; locale?: string; - captionElement?: React.ReactElement | null; + captionElement?: React.ReactElement; onDayClick?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; onDayTouchTap?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; onDayMouseEnter?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; diff --git a/react-dom/index.d.ts b/react-dom/index.d.ts index bf0a246211..00520fc6ed 100644 --- a/react-dom/index.d.ts +++ b/react-dom/index.d.ts @@ -28,7 +28,7 @@ declare namespace ReactDOM { container: Element | null, callback?: (component: T) => any): T; function render

( - element: ReactElement

| null, + element: ReactElement

, container: Element | null, callback?: (component?: Component | Element) => any): Component | Element | void; @@ -57,7 +57,7 @@ declare namespace ReactDOM { callback?: () => any): void; function unstable_renderSubtreeIntoContainer

( parentComponent: Component, - element: ReactElement

| null, + element: ReactElement

, container: Element, callback?: (component?: Component | Element) => any): Component | Element | void; } diff --git a/react-input-mask/index.d.ts b/react-input-mask/index.d.ts index c6acce5858..6fc8c6008f 100644 --- a/react-input-mask/index.d.ts +++ b/react-input-mask/index.d.ts @@ -13,7 +13,7 @@ declare namespace reactInputMask { * * `9`: `0-9` * * `a`: `A-Z, a-z` * * `\*`: `A-Z, a-z, 0-9` - * + * * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` */ mask: string; diff --git a/react-native-scrollable-tab-view/index.d.ts b/react-native-scrollable-tab-view/index.d.ts index 9287ede79d..2f22f1bcf4 100644 --- a/react-native-scrollable-tab-view/index.d.ts +++ b/react-native-scrollable-tab-view/index.d.ts @@ -37,9 +37,9 @@ export interface renderTabBarProperties { interface ScrollableTabViewProperties extends React.Props { /** - * tabBarPosition (String) Defaults to "top". + * tabBarPosition (String) Defaults to "top". * "bottom" to position the tab bar below content. - * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom + * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom * tab bars must consume a style prop on their outer element to support this feature: style={this.props.style}. */ tabBarPosition?: 'top' | 'bottom' | 'overlayTop' | 'overlayBottom'; @@ -50,27 +50,27 @@ interface ScrollableTabViewProperties extends React.Props { initialPage?: number; /** - * (Integer) - set selected tab(can be buggy see + * (Integer) - set selected tab(can be buggy see * https://github.com/skv-headless/react-native-scrollable-tab-view/issues/126 */ page?: number; /** - * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is - * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the + * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is + * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the * tab that is selected */ onChangeTab?: (value: onChangeTabProperties) => void; /** - * onScroll (Function) - function to call when the pages are sliding, + * onScroll (Function) - function to call when the pages are sliding, * should accept 1 argument which is an Float number representing the page position in the slide frame. */ onScroll?: (value: number) => void; /** * renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component - * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, + * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, * and should implement setAnimationValue to be able to animate itself along with the tab content. * You can manually pass the props to the TabBar component. */ @@ -82,7 +82,7 @@ interface ScrollableTabViewProperties extends React.Props { style?: ViewStyle; /** - * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. + * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. * Note that overriding defaults set by the library may break functionality; see the source for details. */ contentProps?: React.ScrollViewProperties; @@ -98,7 +98,7 @@ interface ScrollableTabViewProperties extends React.Props { locked?: boolean; /** - * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all + * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all * the siblings, default to 0 === render current page. */ prerenderingSiblingsNumber?: number; diff --git a/react-native-swiper/react-native-swiper-tests.tsx b/react-native-swiper/react-native-swiper-tests.tsx index c8dae8511e..93cdfcfd18 100644 --- a/react-native-swiper/react-native-swiper-tests.tsx +++ b/react-native-swiper/react-native-swiper-tests.tsx @@ -18,7 +18,7 @@ class SwiperTest extends React.Component { super(props); } - public render(): React.ReactElement | null { + public render(): React.ReactElement { return ( diff --git a/react/index.d.ts b/react/index.d.ts index e39c8c7026..001484aa15 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -171,7 +171,7 @@ declare namespace React { setState(f: (prevState: S, props: P) => Pick, callback?: () => any): void; setState(state: Pick, callback?: () => any): void; forceUpdate(callBack?: () => any): void; - render(): JSX.Element; + render(): JSX.Element | null; // React.Props is now deprecated, which means that the `children` // property is not available on `P` by default, even though you can @@ -2630,7 +2630,7 @@ declare global { namespace JSX { interface Element extends React.ReactElement { } interface ElementClass extends React.Component { - render(): JSX.Element; + render(): JSX.Element | null; } interface ElementAttributesProperty { props: {}; } diff --git a/react/test/tsx.tsx b/react/test/tsx.tsx index 0b0bc096ae..0531cb52c0 100644 --- a/react/test/tsx.tsx +++ b/react/test/tsx.tsx @@ -32,6 +32,3 @@ StatelessComponent2.defaultProps = { ; - -const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null; -const UseComponent2 = (f: boolean) => ; From e791b291058bc8e9e7e5e3c4690f32124ea77b36 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Feb 2017 17:54:17 -0800 Subject: [PATCH 3/3] Fix trailing whitespace that broke test --- react-input-mask/index.d.ts | 2 +- react-native-scrollable-tab-view/index.d.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/react-input-mask/index.d.ts b/react-input-mask/index.d.ts index 6fc8c6008f..c6acce5858 100644 --- a/react-input-mask/index.d.ts +++ b/react-input-mask/index.d.ts @@ -13,7 +13,7 @@ declare namespace reactInputMask { * * `9`: `0-9` * * `a`: `A-Z, a-z` * * `\*`: `A-Z, a-z, 0-9` - * + * * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` */ mask: string; diff --git a/react-native-scrollable-tab-view/index.d.ts b/react-native-scrollable-tab-view/index.d.ts index 2f22f1bcf4..9287ede79d 100644 --- a/react-native-scrollable-tab-view/index.d.ts +++ b/react-native-scrollable-tab-view/index.d.ts @@ -37,9 +37,9 @@ export interface renderTabBarProperties { interface ScrollableTabViewProperties extends React.Props { /** - * tabBarPosition (String) Defaults to "top". + * tabBarPosition (String) Defaults to "top". * "bottom" to position the tab bar below content. - * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom + * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom * tab bars must consume a style prop on their outer element to support this feature: style={this.props.style}. */ tabBarPosition?: 'top' | 'bottom' | 'overlayTop' | 'overlayBottom'; @@ -50,27 +50,27 @@ interface ScrollableTabViewProperties extends React.Props { initialPage?: number; /** - * (Integer) - set selected tab(can be buggy see + * (Integer) - set selected tab(can be buggy see * https://github.com/skv-headless/react-native-scrollable-tab-view/issues/126 */ page?: number; /** - * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is - * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the + * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is + * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the * tab that is selected */ onChangeTab?: (value: onChangeTabProperties) => void; /** - * onScroll (Function) - function to call when the pages are sliding, + * onScroll (Function) - function to call when the pages are sliding, * should accept 1 argument which is an Float number representing the page position in the slide frame. */ onScroll?: (value: number) => void; /** * renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component - * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, + * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, * and should implement setAnimationValue to be able to animate itself along with the tab content. * You can manually pass the props to the TabBar component. */ @@ -82,7 +82,7 @@ interface ScrollableTabViewProperties extends React.Props { style?: ViewStyle; /** - * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. + * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. * Note that overriding defaults set by the library may break functionality; see the source for details. */ contentProps?: React.ScrollViewProperties; @@ -98,7 +98,7 @@ interface ScrollableTabViewProperties extends React.Props { locked?: boolean; /** - * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all + * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all * the siblings, default to 0 === render current page. */ prerenderingSiblingsNumber?: number;