Add type for new "ref" airbnb-prop-type

This commit is contained in:
Andrew Huth
2019-04-04 14:08:34 -07:00
parent 2872bd7761
commit 7d4eaef720
2 changed files with 6 additions and 0 deletions

View File

@@ -152,6 +152,9 @@ AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);
// $ExpectType Requireable<LegacyRef<HTMLElement>>
AirbnbPropTypes.ref();
// $ExpectType Requireable<string | null>
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator<number>

View File

@@ -5,6 +5,7 @@
// TypeScript Version: 3.0
import * as PropTypes from 'prop-types';
import * as React from 'react';
export interface ReactComponentLike {
setState(...args: any[]): any;
@@ -156,6 +157,8 @@ export function range<T extends number>(min?: number, max?: number): PropTypes.R
export function range(min?: number, max?: number): PropTypes.Requireable<number>;
export function ref(): PropTypes.Requireable<React.LegacyRef<HTMLElement>>;
export function requiredBy<P>(
requiredByPropName: string,
propType: PropTypes.Validator<P>,