@types/react 16.9.21 → 16.9.25

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 +44 -5
  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: Thu, 20 Feb 2020 00:44:06 GMT
11
+ * Last updated: Fri, 20 Mar 2020 17:59:38 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), [Kyle Scully](https://github.com/zieka), and [Cong Zhang](https://github.com/dancerphil).
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), [Cong Zhang](https://github.com/dancerphil), and [Dimitri Mitropoulos](https://github.com/dimitropoulos).
react/index.d.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  // Sebastian Silbermann <https://github.com/eps1lon>
23
23
  // Kyle Scully <https://github.com/zieka>
24
24
  // Cong Zhang <https://github.com/dancerphil>
25
+ // Dimitri Mitropoulos <https://github.com/dimitropoulos>
25
26
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
26
27
  // TypeScript Version: 2.8
27
28
 
@@ -81,17 +82,53 @@ declare namespace React {
81
82
  | ((props: P) => ReactElement | null)
82
83
  | (new (props: P) => Component<P, any>);
83
84
 
84
- type Key = string | number;
85
-
86
85
  interface RefObject<T> {
87
86
  readonly current: T | null;
88
87
  }
89
-
90
- type Ref<T> = { bivarianceHack(instance: T | null): void }["bivarianceHack"] | RefObject<T> | null;
88
+ type RefCallback<T> = { bivarianceHack(instance: T | null): void }["bivarianceHack"];
89
+ type Ref<T> = RefCallback<T> | RefObject<T> | null;
91
90
  type LegacyRef<T> = string | Ref<T>;
91
+ /**
92
+ * Gets the instance type for a React element. The instance will be different for various component types:
93
+ *
94
+ * - React class components will be the class instance. So if you had `class Foo extends React.Component<{}> {}`
95
+ * and used `React.ElementRef<typeof Foo>` then the type would be the instance of `Foo`.
96
+ * - React stateless functional components do not have a backing instance and so `React.ElementRef<typeof Bar>`
97
+ * (when `Bar` is `function Bar() {}`) will give you the `undefined` type.
98
+ * - JSX intrinsics like `div` will give you their DOM instance. For `React.ElementRef<'div'>` that would be
99
+ * `HTMLDivElement`. For `React.ElementRef<'input'>` that would be `HTMLInputElement`.
100
+ * - React stateless functional components that forward a `ref` will give you the `ElementRef` of the forwarded
101
+ * to component.
102
+ *
103
+ * `C` must be the type _of_ a React component so you need to use typeof as in React.ElementRef<typeof MyComponent>.
104
+ *
105
+ * @todo In Flow, this works a little different with forwarded refs and the `AbstractComponent` that
106
+ * `React.forwardRef()` returns.
107
+ */
108
+ type ElementRef<
109
+ C extends
110
+ | ForwardRefExoticComponent<any>
111
+ | { new (props: any): Component<any> }
112
+ | ((props: any, context?: any) => ReactElement | null)
113
+ | keyof JSX.IntrinsicElements
114
+ > = C extends ForwardRefExoticComponent<infer FP>
115
+ ? FP extends RefAttributes<infer FC>
116
+ ? FC
117
+ : never
118
+ : C extends { new (props: any): Component<any> }
119
+ ? InstanceType<C>
120
+ : C extends ((props: any, context?: any) => ReactElement | null)
121
+ ? undefined
122
+ : C extends keyof JSX.IntrinsicElements
123
+ ? JSX.IntrinsicElements[C] extends DOMAttributes<infer E>
124
+ ? E
125
+ : never
126
+ : never;
92
127
 
93
128
  type ComponentState = any;
94
129
 
130
+ type Key = string | number;
131
+
95
132
  /**
96
133
  * @internal You shouldn't need to use this type since you never see these attributes
97
134
  * inside your component or have to validate them.
@@ -115,7 +152,7 @@ declare namespace React {
115
152
  interface ReactComponentElement<
116
153
  T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
117
154
  P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, 'key' | 'ref'>>
118
- > extends ReactElement<P, T> { }
155
+ > extends ReactElement<P, Exclude<T, number>> { }
119
156
 
120
157
  /**
121
158
  * @deprecated Please use `FunctionComponentElement`
@@ -2010,6 +2047,7 @@ declare namespace React {
2010
2047
  decoding?: "async" | "auto" | "sync";
2011
2048
  height?: number | string;
2012
2049
  loading?: "eager" | "lazy";
2050
+ referrerPolicy?: "no-referrer" | "origin" | "unsafe-url";
2013
2051
  sizes?: string;
2014
2052
  src?: string;
2015
2053
  srcSet?: string;
@@ -2445,6 +2483,7 @@ declare namespace React {
2445
2483
  overlineThickness?: number | string;
2446
2484
  paintOrder?: number | string;
2447
2485
  panose1?: number | string;
2486
+ path?: string;
2448
2487
  pathLength?: number | string;
2449
2488
  patternContentUnits?: string;
2450
2489
  patternTransform?: number | string;
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "16.9.21",
3
+ "version": "16.9.25",
4
4
  "description": "TypeScript definitions for React",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -110,6 +110,11 @@
110
110
  "name": "Cong Zhang",
111
111
  "url": "https://github.com/dancerphil",
112
112
  "githubUsername": "dancerphil"
113
+ },
114
+ {
115
+ "name": "Dimitri Mitropoulos",
116
+ "url": "https://github.com/dimitropoulos",
117
+ "githubUsername": "dimitropoulos"
113
118
  }
114
119
  ],
115
120
  "main": "",
@@ -124,6 +129,6 @@
124
129
  "@types/prop-types": "*",
125
130
  "csstype": "^2.2.0"
126
131
  },
127
- "typesPublisherContentHash": "2995363f213d73aa3dd84369e03d4ce7c0eaf4486c859ad0083de971b9d85b02",
132
+ "typesPublisherContentHash": "9734b6f2aa660752af997a294f88d260a7d58fdcb17c125c76f79f3d8f9d9555",
128
133
  "typeScriptVersion": "2.8"
129
134
  }