@types/react 16.7.9 → 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 +1 -1
- react/index.d.ts +100 -26
- react/package.json +2 -2
react/README.md
CHANGED
@@ -8,7 +8,7 @@ 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
|
|
react/index.d.ts
CHANGED
@@ -421,6 +421,34 @@ declare namespace React {
|
|
421
421
|
refs: {
|
422
422
|
[key: string]: ReactInstance
|
423
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;
|
424
452
|
}
|
425
453
|
|
426
454
|
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> { }
|
@@ -2636,30 +2664,76 @@ declare namespace React {
|
|
2636
2664
|
*/
|
2637
2665
|
componentStack: string;
|
2638
2666
|
}
|
2639
|
-
}
|
2640
2667
|
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
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
|
+
}
|
2663
2737
|
|
2664
2738
|
declare global {
|
2665
2739
|
namespace JSX {
|
@@ -2675,9 +2749,9 @@ declare global {
|
|
2675
2749
|
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
|
2676
2750
|
type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
|
2677
2751
|
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
|
2678
|
-
? ReactManagedAttributes<U, P>
|
2679
|
-
: ReactManagedAttributes<T, P>
|
2680
|
-
: ReactManagedAttributes<C, P>;
|
2752
|
+
? React.ReactManagedAttributes<U, P>
|
2753
|
+
: React.ReactManagedAttributes<T, P>
|
2754
|
+
: React.ReactManagedAttributes<C, P>;
|
2681
2755
|
|
2682
2756
|
// tslint:disable-next-line:no-empty-interface
|
2683
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": [
|
@@ -108,6 +108,6 @@
|
|
108
108
|
"csstype": "^2.2.0",
|
109
109
|
"@types/prop-types": "*"
|
110
110
|
},
|
111
|
-
"typesPublisherContentHash": "
|
111
|
+
"typesPublisherContentHash": "46c581d5016bb66b4b04968847bb233a19a992c0434d4cf5f5212c12c5d5f1be",
|
112
112
|
"typeScriptVersion": "2.8"
|
113
113
|
}
|