@types/react 16.8.12 → 16.8.13

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.
Files changed (3) hide show
  1. react/README.md +1 -1
  2. react/index.d.ts +14 -9
  3. react/package.json +2 -2
react/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for React ( http://facebook.github.io/rea
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react
9
9
 
10
10
  Additional Details
11
- * Last updated: Wed, 03 Apr 2019 22:06:33 GMT
11
+ * Last updated: Mon, 08 Apr 2019 04:24:39 GMT
12
12
  * Dependencies: @types/csstype, @types/prop-types
13
13
  * Global values: React
14
14
 
react/index.d.ts CHANGED
@@ -2764,16 +2764,21 @@ declare namespace React {
2764
2764
  // so boolean is only resolved for T = any
2765
2765
  type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
2766
2766
 
2767
+ type ExactlyAnyPropertyKeys<T> = { [K in keyof T]: IsExactlyAny<T[K]> extends true ? K : never }[keyof T];
2768
+ type NotExactlyAnyPropertyKeys<T> = Exclude<keyof T, ExactlyAnyPropertyKeys<T>>;
2769
+
2767
2770
  // Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any
2768
- // If props is type any, use propTypes definitions, otherwise for each `any` property of props, use the propTypes type
2769
- // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
2770
- type MergePropTypes<P, T> = IsExactlyAny<P> extends true ? T : ({
2771
- [K in keyof P]: IsExactlyAny<P[K]> extends true
2772
- ? K extends keyof T
2773
- ? T[K]
2774
- : P[K]
2775
- : P[K]
2776
- } & Pick<T, Exclude<keyof T, keyof P>>);
2771
+ type MergePropTypes<P, T> =
2772
+ // If props is type any, use propTypes definitions
2773
+ IsExactlyAny<P> extends true ? T :
2774
+ // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
2775
+ string extends keyof P ? P :
2776
+ // Prefer declared types which are not exactly any
2777
+ & Pick<P, NotExactlyAnyPropertyKeys<P>>
2778
+ // For props which are exactly any, use the type inferred from propTypes if present
2779
+ & Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
2780
+ // Keep leftover props not specified in propTypes
2781
+ & Pick<P, Exclude<keyof P, keyof T>>;
2777
2782
 
2778
2783
  // Any prop that has a default prop becomes optional, but its type is unchanged
2779
2784
  // Undeclared default props are augmented into the resulting allowable attributes
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "16.8.12",
3
+ "version": "16.8.13",
4
4
  "description": "TypeScript definitions for React",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -129,6 +129,6 @@
129
129
  "@types/prop-types": "*",
130
130
  "csstype": "^2.2.0"
131
131
  },
132
- "typesPublisherContentHash": "af8adbb3e739192b8b5edd70644fd5fdfcb52ed08365e7da394bda9556f4c574",
132
+ "typesPublisherContentHash": "53d31798b997bfdad69e11ba927c3df23f4f9df1aa3888dfb9b4d665e7a2e946",
133
133
  "typeScriptVersion": "2.8"
134
134
  }