From d79f340d574873ca4deabd545ee4b9fdab1164ec Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 27 Jan 2017 15:23:51 -0800 Subject: [PATCH] Add tests and fix broken test --- 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, 19 insertions(+), 16 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index 01c5492922..f2993d95c5 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; + captionElement?: React.ReactElement | null; 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 00520fc6ed..bf0a246211 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

, + element: ReactElement

| null, 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

, + element: ReactElement

| null, 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 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; diff --git a/react-native-swiper/react-native-swiper-tests.tsx b/react-native-swiper/react-native-swiper-tests.tsx index 93cdfcfd18..c8dae8511e 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 { + public render(): React.ReactElement | null { return ( diff --git a/react/index.d.ts b/react/index.d.ts index 6f88127305..61aa81ab01 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -168,7 +168,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 | null; + render(): JSX.Element; // React.Props is now deprecated, which means that the `children` // property is not available on `P` by default, even though you can @@ -2624,7 +2624,7 @@ declare global { type Element = JSXElement | null; interface ElementClass extends React.Component { - render(): JSX.Element | null; + render(): JSX.Element; } interface ElementAttributesProperty { props: {}; } diff --git a/react/test/tsx.tsx b/react/test/tsx.tsx index 0531cb52c0..0b0bc096ae 100644 --- a/react/test/tsx.tsx +++ b/react/test/tsx.tsx @@ -32,3 +32,6 @@ StatelessComponent2.defaultProps = { ; + +const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null; +const UseComponent2 = (f: boolean) => ;