mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Implement our own Ref type
So that we do not need a dependency on @types/react.
This commit is contained in:
@@ -152,7 +152,7 @@ AirbnbPropTypes.range(0, 10);
|
||||
// $ExpectType Requireable<5>
|
||||
AirbnbPropTypes.range<5>(0, 10);
|
||||
|
||||
// $ExpectType Requireable<LegacyRef<HTMLElement>>
|
||||
// $ExpectType Requireable<ReactLegacyRefLike<HTMLElement>>
|
||||
AirbnbPropTypes.ref();
|
||||
|
||||
// $ExpectType Requireable<string | null>
|
||||
|
||||
Vendored
+7
-2
@@ -5,7 +5,6 @@
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import * as PropTypes from 'prop-types';
|
||||
import * as React from 'react';
|
||||
|
||||
export interface ReactComponentLike {
|
||||
setState(...args: any[]): any;
|
||||
@@ -25,6 +24,12 @@ export type ReactFunctionComponentLike = (...args: any[]) => PropTypes.ReactNode
|
||||
|
||||
export type ReactTypeLike = string | ReactClassComponentLike | ReactFunctionComponentLike;
|
||||
|
||||
export interface ReactRefLike<T> {
|
||||
readonly current: T | null;
|
||||
}
|
||||
|
||||
export type ReactLegacyRefLike<T> = (instance: T | null) => void | ReactRefLike<T> | null;
|
||||
|
||||
export interface Specifier<T = any> {
|
||||
max?: number;
|
||||
min?: number;
|
||||
@@ -157,7 +162,7 @@ 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 ref(): PropTypes.Requireable<ReactLegacyRefLike<HTMLElement>>;
|
||||
|
||||
export function requiredBy<P>(
|
||||
requiredByPropName: string,
|
||||
|
||||
Reference in New Issue
Block a user