@types/react 16.9.16 → 16.9.17

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 +2 -2
  2. react/index.d.ts +39 -0
  3. react/package.json +7 -2
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: Mon, 09 Dec 2019 12:34:40 GMT
11
+ * Last updated: Fri, 20 Dec 2019 07:06:52 GMT
12
12
  * Dependencies: [@types/csstype](https://npmjs.com/package/@types/csstype), [@types/prop-types](https://npmjs.com/package/@types/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), Dovydas Navickas (https://github.com/DovydasNavickas), 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/Jessidhia), Saransh Kataria (https://github.com/saranshkataria), Kanitkorn Sujautra (https://github.com/lukyth), Sebastian Silbermann (https://github.com/eps1lon), and Kyle Scully (https://github.com/zieka).
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), Dovydas Navickas (https://github.com/DovydasNavickas), 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/Jessidhia), Saransh Kataria (https://github.com/saranshkataria), Kanitkorn Sujautra (https://github.com/lukyth), Sebastian Silbermann (https://github.com/eps1lon), Kyle Scully (https://github.com/zieka), and Cong Zhang (https://github.com/dancerphil).
react/index.d.ts CHANGED
@@ -21,6 +21,7 @@
21
21
  // Kanitkorn Sujautra <https://github.com/lukyth>
22
22
  // Sebastian Silbermann <https://github.com/eps1lon>
23
23
  // Kyle Scully <https://github.com/zieka>
24
+ // Cong Zhang <https://github.com/dancerphil>
24
25
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
25
26
  // TypeScript Version: 2.8
26
27
 
@@ -822,13 +823,19 @@ declare namespace React {
822
823
  // this technically does accept a second argument, but it's already under a deprecation warning
823
824
  // and it's not even released so probably better to not define it.
824
825
  type Dispatch<A> = (value: A) => void;
826
+ // Since action _can_ be undefined, dispatch may be called without any parameters.
827
+ type DispatchWithoutAction = () => void;
825
828
  // Unlike redux, the actions _can_ be anything
826
829
  type Reducer<S, A> = (prevState: S, action: A) => S;
830
+ // If useReducer accepts a reducer without action, dispatch may be called without any parameters.
831
+ type ReducerWithoutAction<S> = (prevState: S) => S;
827
832
  // types used to try and prevent the compiler from reducing S
828
833
  // to a supertype common with the second argument to useReducer()
829
834
  type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
830
835
  type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
831
836
  // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
837
+ type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> =
838
+ R extends ReducerWithoutAction<infer S> ? S : never;
832
839
  // TODO (TypeScript 3.0): ReadonlyArray<unknown>
833
840
  type DependencyList = ReadonlyArray<any>;
834
841
 
@@ -864,6 +871,38 @@ declare namespace React {
864
871
  * @see https://reactjs.org/docs/hooks-reference.html#usestate
865
872
  */
866
873
  function useState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
874
+ /**
875
+ * An alternative to `useState`.
876
+ *
877
+ * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
878
+ * multiple sub-values. It also lets you optimize performance for components that trigger deep
879
+ * updates because you can pass `dispatch` down instead of callbacks.
880
+ *
881
+ * @version 16.8.0
882
+ * @see https://reactjs.org/docs/hooks-reference.html#usereducer
883
+ */
884
+ // overload where dispatch could accept 0 arguments.
885
+ function useReducer<R extends ReducerWithoutAction<any>, I>(
886
+ reducer: R,
887
+ initializerArg: I,
888
+ initializer: (arg: I) => ReducerStateWithoutAction<R>
889
+ ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
890
+ /**
891
+ * An alternative to `useState`.
892
+ *
893
+ * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
894
+ * multiple sub-values. It also lets you optimize performance for components that trigger deep
895
+ * updates because you can pass `dispatch` down instead of callbacks.
896
+ *
897
+ * @version 16.8.0
898
+ * @see https://reactjs.org/docs/hooks-reference.html#usereducer
899
+ */
900
+ // overload where dispatch could accept 0 arguments.
901
+ function useReducer<R extends ReducerWithoutAction<any>>(
902
+ reducer: R,
903
+ initializerArg: ReducerStateWithoutAction<R>,
904
+ initializer?: undefined
905
+ ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
867
906
  /**
868
907
  * An alternative to `useState`.
869
908
  *
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "16.9.16",
3
+ "version": "16.9.17",
4
4
  "description": "TypeScript definitions for React",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -105,6 +105,11 @@
105
105
  "name": "Kyle Scully",
106
106
  "url": "https://github.com/zieka",
107
107
  "githubUsername": "zieka"
108
+ },
109
+ {
110
+ "name": "Cong Zhang",
111
+ "url": "https://github.com/dancerphil",
112
+ "githubUsername": "dancerphil"
108
113
  }
109
114
  ],
110
115
  "main": "",
@@ -119,6 +124,6 @@
119
124
  "@types/prop-types": "*",
120
125
  "csstype": "^2.2.0"
121
126
  },
122
- "typesPublisherContentHash": "5b75e5de8a74e4d5c5eeec7098d59061123959a5b60b52e9f1fd0933d56d86f4",
127
+ "typesPublisherContentHash": "33aa32e48fbbb170b424b0f0b5aeb7a6d5107933a14e081994a389904942163c",
123
128
  "typeScriptVersion": "2.8"
124
129
  }