@types/react 16.7.6 → 16.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- react/README.md +2 -2
- react/index.d.ts +109 -33
- react/package.json +2 -7
react/README.md
CHANGED
@@ -8,9 +8,9 @@ This package contains type definitions for React (http://facebook.github.io/reac
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react
|
9
9
|
|
10
10
|
Additional Details
|
11
|
-
* Last updated:
|
11
|
+
* Last updated: Fri, 30 Nov 2018 06:26:44 GMT
|
12
12
|
* Dependencies: csstype, prop-types
|
13
13
|
* Global values: React
|
14
14
|
|
15
15
|
# Credits
|
16
|
-
These definitions were written by Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>, John Reilly <https://github.com/johnnyreilly>, Benoit Benezech <https://github.com/bbenezech>, Patricio Zavolinsky <https://github.com/pzavolinsky>, Digiguru <https://github.com/digiguru>, Eric Anderson <https://github.com/ericanderson>,
|
16
|
+
These definitions were written by Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>, John Reilly <https://github.com/johnnyreilly>, Benoit Benezech <https://github.com/bbenezech>, Patricio Zavolinsky <https://github.com/pzavolinsky>, Digiguru <https://github.com/digiguru>, Eric Anderson <https://github.com/ericanderson>, Tanguy Krotoff <https://github.com/tkrotoff>, Dovydas Navickas <https://github.com/DovydasNavickas>, Stéphane Goetz <https://github.com/onigoetz>, Josh Rutherford <https://github.com/theruther4d>, Guilherme Hübner <https://github.com/guilhermehubner>, Ferdy Budhidharma <https://github.com/ferdaber>, Johann Rakotoharisoa <https://github.com/jrakotoharisoa>, Olivier Pascal <https://github.com/pascaloliv>, Martin Hochel <https://github.com/hotell>, Frank Li <https://github.com/franklixuefei>, Jessica Franco <https://github.com/Kovensky>.
|
react/index.d.ts
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
// Patricio Zavolinsky <https://github.com/pzavolinsky>
|
9
9
|
// Digiguru <https://github.com/digiguru>
|
10
10
|
// Eric Anderson <https://github.com/ericanderson>
|
11
|
-
// Albert Kurniawan <https://github.com/morcerf>
|
12
11
|
// Tanguy Krotoff <https://github.com/tkrotoff>
|
13
12
|
// Dovydas Navickas <https://github.com/DovydasNavickas>
|
14
13
|
// Stéphane Goetz <https://github.com/onigoetz>
|
@@ -50,7 +49,11 @@ declare namespace React {
|
|
50
49
|
// React Elements
|
51
50
|
// ----------------------------------------------------------------------
|
52
51
|
|
53
|
-
type ReactType<P = any> =
|
52
|
+
type ReactType<P = any> =
|
53
|
+
{
|
54
|
+
[K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never
|
55
|
+
}[keyof JSX.IntrinsicElements] |
|
56
|
+
ComponentType<P>;
|
54
57
|
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
55
58
|
|
56
59
|
type Key = string | number;
|
@@ -418,6 +421,34 @@ declare namespace React {
|
|
418
421
|
refs: {
|
419
422
|
[key: string]: ReactInstance
|
420
423
|
};
|
424
|
+
|
425
|
+
// Static properties copied from ComponentClass interface.
|
426
|
+
/**
|
427
|
+
* The validity of the type of `propTypes` cannot be checked
|
428
|
+
* automatically at the definition of a component class because the
|
429
|
+
* required type depends on `P`. We recommend checking it using
|
430
|
+
* `asPropTypes` from the `react-typescript-helpers` package. If you
|
431
|
+
* don't do that, then the type will still be checked by
|
432
|
+
* JSX.LibraryManagedAttributes every time the component is used,
|
433
|
+
* assuming you use TypeScript 3.0 or newer.
|
434
|
+
*/
|
435
|
+
// Note: `propTypes` and `defaultProps` need to be `any` so that a
|
436
|
+
// component class that does not redeclare them is assignable to
|
437
|
+
// `ComponentClass<P>`.
|
438
|
+
static propTypes?: any;
|
439
|
+
static contextTypes?: ValidationMap<any>;
|
440
|
+
static childContextTypes?: ValidationMap<any>;
|
441
|
+
/**
|
442
|
+
* The validity of the type of `defaultProps` cannot be checked
|
443
|
+
* automatically at the definition of a component class because the
|
444
|
+
* required type depends on `P`. We recommend checking it using
|
445
|
+
* `asDefaultProps` from the `react-typescript-helpers` package. If you
|
446
|
+
* don't do that, then the type will still be checked by
|
447
|
+
* JSX.LibraryManagedAttributes every time the component is used,
|
448
|
+
* assuming you use TypeScript 3.0 or newer.
|
449
|
+
*/
|
450
|
+
static defaultProps?: any;
|
451
|
+
static displayName?: string;
|
421
452
|
}
|
422
453
|
|
423
454
|
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> { }
|
@@ -492,8 +523,7 @@ declare namespace React {
|
|
492
523
|
*/
|
493
524
|
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
494
525
|
C &
|
495
|
-
(new (props: P, context?: any) => T)
|
496
|
-
(new (props: P, context?: any) => { props: P });
|
526
|
+
(new (props: P, context?: any) => T);
|
497
527
|
|
498
528
|
//
|
499
529
|
// Component Specs and Lifecycle
|
@@ -714,17 +744,17 @@ declare namespace React {
|
|
714
744
|
* NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,
|
715
745
|
* or ComponentPropsWithoutRef when refs are not supported.
|
716
746
|
*/
|
717
|
-
type ComponentProps<T extends
|
747
|
+
type ComponentProps<T extends ReactType> =
|
718
748
|
T extends ComponentType<infer P>
|
719
749
|
? P
|
720
750
|
: T extends keyof JSX.IntrinsicElements
|
721
751
|
? JSX.IntrinsicElements[T]
|
722
752
|
: {};
|
723
|
-
type ComponentPropsWithRef<T extends
|
753
|
+
type ComponentPropsWithRef<T extends ReactType> =
|
724
754
|
T extends ComponentClass<infer P>
|
725
755
|
? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
|
726
756
|
: PropsWithRef<ComponentProps<T>>;
|
727
|
-
type ComponentPropsWithoutRef<T extends
|
757
|
+
type ComponentPropsWithoutRef<T extends ReactType> =
|
728
758
|
PropsWithoutRef<ComponentProps<T>>;
|
729
759
|
|
730
760
|
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
@@ -2634,30 +2664,76 @@ declare namespace React {
|
|
2634
2664
|
*/
|
2635
2665
|
componentStack: string;
|
2636
2666
|
}
|
2637
|
-
}
|
2638
2667
|
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2668
|
+
const Invalid_propTypes: unique symbol;
|
2669
|
+
/**
|
2670
|
+
* Dummy interface that is intersected into the props type of a component on
|
2671
|
+
* use to generate an error if the component's `propTypes` static property
|
2672
|
+
* is invalid. In most cases, you can get more information about the
|
2673
|
+
* problem with the `propTypes` by trying to assign the component to a
|
2674
|
+
* variable of type `React.ComponentType<P>` where `P` is the appropriate
|
2675
|
+
* props type. You can bypass the type checking of `propTypes` by defining
|
2676
|
+
* a static property named `bypassPropTypesTypecheck`.
|
2677
|
+
*/
|
2678
|
+
interface Invalid_propTypes<P, T> {
|
2679
|
+
[Invalid_propTypes]: never;
|
2680
|
+
}
|
2681
|
+
|
2682
|
+
const Invalid_defaultProps: unique symbol;
|
2683
|
+
/**
|
2684
|
+
* Dummy interface that is intersected into the props type of a component on
|
2685
|
+
* use to generate an error if the component's `defaultProps` static
|
2686
|
+
* property is invalid. In most cases, you can get more information about
|
2687
|
+
* the problem with the `defaultProps` by trying to assign the component to
|
2688
|
+
* a variable of type `React.ComponentType<P>` where `P` is the appropriate
|
2689
|
+
* props type. You can bypass the type checking of `defaultProps` by
|
2690
|
+
* defining a static property named `bypassDefaultPropsTypecheck`.
|
2691
|
+
*/
|
2692
|
+
interface Invalid_defaultProps<P, D> {
|
2693
|
+
[Invalid_defaultProps]: never;
|
2694
|
+
}
|
2695
|
+
|
2696
|
+
// For a component class, the P passed to JSX.LibraryManagedAttributes is
|
2697
|
+
// based on the `props` property and includes `children` regardless of
|
2698
|
+
// whether the original props type (the `P` type argument to
|
2699
|
+
// React.Component) does. However, it's common for component classes not
|
2700
|
+
// to list `children` in the `propTypes` if the original props type did not
|
2701
|
+
// include `children`. We accommodate that here by making the validator for
|
2702
|
+
// `children` optional.
|
2703
|
+
type ValidationMapWithOptionalChildren<P> =
|
2704
|
+
ValidationMap<Pick<P, Exclude<keyof P, "children">>> &
|
2705
|
+
Partial<ValidationMap<Pick<P, Extract<keyof P, "children">>>>;
|
2706
|
+
|
2707
|
+
// Explicitly check for excess properties in CheckPropTypes and
|
2708
|
+
// CheckDefaultProps because by the time we get to
|
2709
|
+
// JSX.LibraryManagedAttributes, we have lost the opportunity to do an
|
2710
|
+
// excess properties check on the original object literal.
|
2711
|
+
|
2712
|
+
type CheckPropTypes<P, T> =
|
2713
|
+
// This condition attempts to single out `T = any`, which needs to bypass the rest of the check
|
2714
|
+
// because `keyof T` would come out as not extending `keyof P`.
|
2715
|
+
T extends typeof Invalid_propTypes ? {} :
|
2716
|
+
[keyof T, T] extends [keyof P, ValidationMapWithOptionalChildren<P>] ? {} : Invalid_propTypes<P, T>;
|
2717
|
+
|
2718
|
+
type CheckDefaultProps<P, D> =
|
2719
|
+
D extends typeof Invalid_defaultProps ? {} :
|
2720
|
+
[keyof D, D] extends [keyof P, Partial<P>] ? {} : Invalid_defaultProps<P, D>;
|
2721
|
+
|
2722
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
2723
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
2724
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
2725
|
+
type Defaultize<P, D> = P extends any
|
2726
|
+
? string extends keyof P ? P :
|
2727
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
2728
|
+
& Partial<Pick<P, Extract<keyof P, keyof D>>>
|
2729
|
+
: never;
|
2730
|
+
|
2731
|
+
type ReactManagedAttributes<C, P> =
|
2732
|
+
(C extends { propTypes: infer T; }
|
2733
|
+
? (C extends { bypassPropTypesTypecheck: {}; } ? {} : CheckPropTypes<P, T>) : {}) &
|
2734
|
+
(C extends { defaultProps: infer D; }
|
2735
|
+
? (C extends { bypassDefaultPropsTypecheck: {}; } ? {} : CheckDefaultProps<P, D>) & Defaultize<P, D> : P);
|
2736
|
+
}
|
2661
2737
|
|
2662
2738
|
declare global {
|
2663
2739
|
namespace JSX {
|
@@ -2673,9 +2749,9 @@ declare global {
|
|
2673
2749
|
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
|
2674
2750
|
type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
|
2675
2751
|
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
|
2676
|
-
? ReactManagedAttributes<U, P>
|
2677
|
-
: ReactManagedAttributes<T, P>
|
2678
|
-
: ReactManagedAttributes<C, P>;
|
2752
|
+
? React.ReactManagedAttributes<U, P>
|
2753
|
+
: React.ReactManagedAttributes<T, P>
|
2754
|
+
: React.ReactManagedAttributes<C, P>;
|
2679
2755
|
|
2680
2756
|
// tslint:disable-next-line:no-empty-interface
|
2681
2757
|
interface IntrinsicAttributes extends React.Attributes { }
|
react/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react",
|
3
|
-
"version": "16.7.
|
3
|
+
"version": "16.7.10",
|
4
4
|
"description": "TypeScript definitions for React",
|
5
5
|
"license": "MIT",
|
6
6
|
"contributors": [
|
@@ -41,11 +41,6 @@
|
|
41
41
|
"url": "https://github.com/ericanderson",
|
42
42
|
"githubUsername": "ericanderson"
|
43
43
|
},
|
44
|
-
{
|
45
|
-
"name": "Albert Kurniawan",
|
46
|
-
"url": "https://github.com/morcerf",
|
47
|
-
"githubUsername": "morcerf"
|
48
|
-
},
|
49
44
|
{
|
50
45
|
"name": "Tanguy Krotoff",
|
51
46
|
"url": "https://github.com/tkrotoff",
|
@@ -113,6 +108,6 @@
|
|
113
108
|
"csstype": "^2.2.0",
|
114
109
|
"@types/prop-types": "*"
|
115
110
|
},
|
116
|
-
"typesPublisherContentHash": "
|
111
|
+
"typesPublisherContentHash": "46c581d5016bb66b4b04968847bb233a19a992c0434d4cf5f5212c12c5d5f1be",
|
117
112
|
"typeScriptVersion": "2.8"
|
118
113
|
}
|