diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index ad8abe57fd..98f6c92c3f 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -31,6 +31,7 @@ /// /// +import * as PropTypes from 'prop-types'; import * as React from 'react'; type Constructor = new(...args: any[]) => T; @@ -8936,7 +8937,7 @@ export const PixelRatio: PixelRatioStatic; export interface ComponentInterface

{ name?: string; displayName?: string; - propTypes: P; + propTypes: PropTypes.ValidationMap

; } /** @@ -8958,7 +8959,7 @@ export function requireNativeComponent

( viewName: string, componentInterface?: ComponentInterface

, extraConfig?: { nativeOnly?: any } -): React.ComponentClass

; +): React.ComponentClass>>; export function findNodeHandle( componentOrHandle: null | number | React.Component | React.ComponentClass @@ -9001,10 +9002,10 @@ export namespace addons { // // Prop Types // -export const ColorPropType: React.Requireable; -export const EdgeInsetsPropType: React.Requireable; -export const PointPropType: React.Requireable; -export const ViewPropTypes: React.Requireable; +export const ColorPropType: React.Validator; +export const EdgeInsetsPropType: React.Validator; +export const PointPropType: React.Validator; +export const ViewPropTypes: React.ValidationMap; declare global { function require(name: string): any; diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 8bc6757c48..b2b66ee2da 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -20,6 +20,7 @@ import { BackAndroid, BackHandler, Button, + ColorPropType, DataSourceAssetCallback, DeviceEventEmitterStatic, Dimensions, @@ -73,6 +74,7 @@ import { KeyboardAvoidingView, Modal, TimePickerAndroid, + ViewPropTypes, } from "react-native"; declare module "react-native" { @@ -186,13 +188,20 @@ const testNativeSyntheticEvent = (e: NativeSyntheticEvent): voi e.nativeEvent; } +type ElementProps = C extends React.Component ? P : never; + class CustomView extends React.Component { render() { return Custom View; } } -class Welcome extends React.Component { +class Welcome extends React.Component & { color: string }> { + static propTypes = { + ...ViewPropTypes, + color: ColorPropType, + }; + refs: { [key: string]: any; rootView: View; @@ -218,8 +227,9 @@ class Welcome extends React.Component { } render() { + const { color, ...props } = this.props; return ( - + Welcome to React Native To get started, edit index.ios.js