@types/react 18.2.50 → 18.2.52

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 +413 -70
  3. react/package.json +2 -2
react/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for react (https://react.dev/).
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, 01 Feb 2024 07:35:21 GMT
11
+ * Last updated: Sat, 03 Feb 2024 00:50:19 GMT
12
12
  * Dependencies: [@types/prop-types](https://npmjs.com/package/@types/prop-types), [@types/scheduler](https://npmjs.com/package/@types/scheduler), [csstype](https://npmjs.com/package/csstype)
13
13
 
14
14
  # Credits
react/index.d.ts CHANGED
@@ -20,11 +20,26 @@ type NativePointerEvent = PointerEvent;
20
20
  type NativeTransitionEvent = TransitionEvent;
21
21
  type NativeUIEvent = UIEvent;
22
22
  type NativeWheelEvent = WheelEvent;
23
+
24
+ /**
25
+ * Used to represent DOM API's where users can either pass
26
+ * true or false as a boolean or as its equivalent strings.
27
+ */
23
28
  type Booleanish = boolean | "true" | "false";
29
+
30
+ /**
31
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin MDN}
32
+ */
24
33
  type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
25
34
 
26
35
  declare const UNDEFINED_VOID_ONLY: unique symbol;
27
- // Destructors are only allowed to return void.
36
+
37
+ /**
38
+ * The function returned from an effect passed to {@link React.useEffect useEffect},
39
+ * which can be used to clean up the effect when the component unmounts.
40
+ *
41
+ * @see {@link https://react.dev/reference/react/useEffect React Docs}
42
+ */
28
43
  type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };
29
44
  type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
30
45
 
@@ -37,33 +52,128 @@ declare namespace React {
37
52
  // React Elements
38
53
  // ----------------------------------------------------------------------
39
54
 
55
+ /**
56
+ * Used to retrieve the possible components which accept a given set of props.
57
+ *
58
+ * Can be passed no type parameters to get a union of all possible components
59
+ * and tags.
60
+ *
61
+ * Is a superset of {@link ComponentType}.
62
+ *
63
+ * @template P The props to match against. If not passed, defaults to any.
64
+ * @template Tag An optional tag to match against. If not passed, attempts to match against all possible tags.
65
+ *
66
+ * @example
67
+ *
68
+ * ```tsx
69
+ * // All components and tags (img, embed etc.)
70
+ * // which accept `src`
71
+ * type SrcComponents = ElementType<{ src: any }>;
72
+ * ```
73
+ *
74
+ * @example
75
+ *
76
+ * ```tsx
77
+ * // All components
78
+ * type AllComponents = ElementType;
79
+ * ```
80
+ *
81
+ * @example
82
+ *
83
+ * ```tsx
84
+ * // All custom components which match `src`, and tags which
85
+ * // match `src`, narrowed down to just `audio` and `embed`
86
+ * type SrcComponents = ElementType<{ src: any }, 'audio' | 'embed'>;
87
+ * ```
88
+ */
40
89
  type ElementType<P = any, Tag extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements> =
41
90
  | { [K in Tag]: P extends JSX.IntrinsicElements[K] ? K : never }[Tag]
42
91
  | ComponentType<P>;
92
+
93
+ /**
94
+ * Represents any user-defined component, either as a function component or
95
+ * a class component.
96
+ *
97
+ * @template P The props the component accepts.
98
+ *
99
+ * @see {@link ComponentClass}
100
+ * @see {@link FunctionComponent}
101
+ */
43
102
  type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
44
103
 
45
104
  type JSXElementConstructor<P> =
46
105
  | ((
47
106
  props: P,
48
107
  /**
49
- * @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components
108
+ * @deprecated
109
+ *
110
+ * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components React Docs}
50
111
  */
51
112
  deprecatedLegacyContext?: any,
52
113
  ) => ReactNode)
53
114
  | (new(
54
115
  props: P,
55
116
  /**
56
- * @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods
117
+ * @deprecated
118
+ *
119
+ * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
57
120
  */
58
121
  deprecatedLegacyContext?: any,
59
122
  ) => Component<any, any>);
60
123
 
124
+ /**
125
+ * A readonly ref container where {@link current} cannot be mutated.
126
+ *
127
+ * Created by {@link createRef}, or {@link useRef} when passed `null`.
128
+ *
129
+ * @template T The type of the ref's value.
130
+ *
131
+ * @example
132
+ *
133
+ * ```tsx
134
+ * const ref = createRef<HTMLDivElement>();
135
+ *
136
+ * ref.current = document.createElement('div'); // Error
137
+ * ```
138
+ */
61
139
  interface RefObject<T> {
62
140
  readonly current: T | null;
63
141
  }
64
- // Bivariance hack for consistent unsoundness with RefObject
142
+
143
+ /**
144
+ * A callback fired whenever the ref's value changes.
145
+ *
146
+ * @template T The type of the ref's value.
147
+ *
148
+ * @see {@link https://react.dev/reference/react-dom/components/common#ref-callback React Docs}
149
+ *
150
+ * @example
151
+ *
152
+ * ```tsx
153
+ * <div ref={(node) => console.log(node)} />
154
+ * ```
155
+ */
65
156
  type RefCallback<T> = { bivarianceHack(instance: T | null): void }["bivarianceHack"];
157
+
158
+ /**
159
+ * A union type of all possible shapes for React refs.
160
+ *
161
+ * @see {@link RefCallback}
162
+ * @see {@link RefObject}
163
+ */
164
+
66
165
  type Ref<T> = RefCallback<T> | RefObject<T> | null;
166
+ /**
167
+ * A legacy implementation of refs where you can pass a string to a ref prop.
168
+ *
169
+ * @see {@link https://react.dev/reference/react/Component#refs React Docs}
170
+ *
171
+ * @example
172
+ *
173
+ * ```tsx
174
+ * <div ref="myRef" />
175
+ * ```
176
+ */
67
177
  type LegacyRef<T> = string | Ref<T>;
68
178
  /**
69
179
  * Gets the instance type for a React element. The instance will be different for various component types:
@@ -99,6 +209,11 @@ declare namespace React {
99
209
 
100
210
  type ComponentState = any;
101
211
 
212
+ /**
213
+ * A value which uniquely identifies a node among items in an array.
214
+ *
215
+ * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}
216
+ */
102
217
  type Key = string | number | bigint;
103
218
 
104
219
  /**
@@ -112,7 +227,7 @@ declare namespace React {
112
227
  /**
113
228
  * Allows getting a ref to the component instance.
114
229
  * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
115
- * @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
230
+ * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom}
116
231
  */
117
232
  ref?: Ref<T> | undefined;
118
233
  }
@@ -120,7 +235,7 @@ declare namespace React {
120
235
  /**
121
236
  * Allows getting a ref to the component instance.
122
237
  * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
123
- * @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
238
+ * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom}
124
239
  */
125
240
  ref?: LegacyRef<T> | undefined;
126
241
  }
@@ -372,18 +487,14 @@ declare namespace React {
372
487
  }
373
488
 
374
489
  /**
375
- * An object masquerading as a component. These are created by
376
- * {@link forwardRef}, {@link memo}, and {@link createContext}.
490
+ * An object masquerading as a component. These are created by functions
491
+ * like {@link forwardRef}, {@link memo}, and {@link createContext}.
377
492
  *
378
493
  * In order to make TypeScript work, we pretend that they are normal
379
494
  * components.
380
495
  *
381
496
  * But they are, in fact, not callable - instead, they are objects which
382
497
  * are treated specially by the renderer.
383
- *
384
- * @see {@link forwardRef}
385
- * @see {@link memo}
386
- * @see {@link createContext}
387
498
  */
388
499
  interface ExoticComponent<P = {}> {
389
500
  (props: P): ReactNode;
@@ -404,24 +515,122 @@ declare namespace React {
404
515
  displayName?: string | undefined;
405
516
  }
406
517
 
518
+ /**
519
+ * An {@link ExoticComponent} with a `propTypes` property applied to it.
520
+ */
407
521
  interface ProviderExoticComponent<P> extends ExoticComponent<P> {
408
522
  propTypes?: WeakValidationMap<P> | undefined;
409
523
  }
410
524
 
525
+ /**
526
+ * Used to retrieve the type of a context object from a {@link Context}.
527
+ *
528
+ * @example
529
+ *
530
+ * ```tsx
531
+ * import { createContext } from 'react';
532
+ *
533
+ * const MyContext = createContext({ foo: 'bar' });
534
+ *
535
+ * type ContextType = ContextType<typeof MyContext>;
536
+ * // ContextType = { foo: string }
537
+ * ```
538
+ */
411
539
  type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
412
540
 
413
- // NOTE: only the Context object itself can get a displayName
414
- // https://github.com/facebook/react-devtools/blob/e0b854e4c/backend/attachRendererFiber.js#L310-L325
541
+ /**
542
+ * Wraps your components to specify the value of this context for all components inside.
543
+ *
544
+ * @see {@link https://react.dev/reference/react/createContext#provider React Docs}
545
+ *
546
+ * @example
547
+ *
548
+ * ```tsx
549
+ * import { createContext } from 'react';
550
+ *
551
+ * const ThemeContext = createContext('light');
552
+ *
553
+ * function App() {
554
+ * return (
555
+ * <ThemeContext.Provider value="dark">
556
+ * <Toolbar />
557
+ * </ThemeContext.Provider>
558
+ * );
559
+ * }
560
+ * ```
561
+ */
415
562
  type Provider<T> = ProviderExoticComponent<ProviderProps<T>>;
563
+
564
+ /**
565
+ * The old way to read context, before {@link useContext} existed.
566
+ *
567
+ * @see {@link https://react.dev/reference/react/createContext#consumer React Docs}
568
+ *
569
+ * @example
570
+ *
571
+ * ```tsx
572
+ * import { UserContext } from './user-context';
573
+ *
574
+ * function Avatar() {
575
+ * return (
576
+ * <UserContext.Consumer>
577
+ * {user => <img src={user.profileImage} alt={user.name} />}
578
+ * </UserContext.Consumer>
579
+ * );
580
+ * }
581
+ * ```
582
+ */
416
583
  type Consumer<T> = ExoticComponent<ConsumerProps<T>>;
584
+
585
+ /**
586
+ * Context lets components pass information deep down without explicitly
587
+ * passing props.
588
+ *
589
+ * Created from {@link createContext}
590
+ *
591
+ * @see {@link https://react.dev/learn/passing-data-deeply-with-context React Docs}
592
+ * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
593
+ *
594
+ * @example
595
+ *
596
+ * ```tsx
597
+ * import { createContext } from 'react';
598
+ *
599
+ * const ThemeContext = createContext('light');
600
+ * ```
601
+ */
417
602
  interface Context<T> {
418
603
  Provider: Provider<T>;
419
604
  Consumer: Consumer<T>;
605
+ /**
606
+ * Used in debugging messages. You might want to set it
607
+ * explicitly if you want to display a different name for
608
+ * debugging purposes.
609
+ *
610
+ * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
611
+ */
420
612
  displayName?: string | undefined;
421
613
  }
614
+
615
+ /**
616
+ * Lets you create a {@link Context} that components can provide or read.
617
+ *
618
+ * @param defaultValue The value you want the context to have when there is no matching
619
+ * {@link Provider} in the tree above the component reading the context. This is meant
620
+ * as a "last resort" fallback.
621
+ *
622
+ * @see {@link https://react.dev/reference/react/createContext#reference React Docs}
623
+ * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
624
+ *
625
+ * @example
626
+ *
627
+ * ```tsx
628
+ * import { createContext } from 'react';
629
+ *
630
+ * const ThemeContext = createContext('light');
631
+ * ```
632
+ */
422
633
  function createContext<T>(
423
- // If you thought this should be optional, see
424
- // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106
425
634
  defaultValue: T,
426
635
  ): Context<T>;
427
636
 
@@ -438,9 +647,57 @@ declare namespace React {
438
647
  only<C>(children: C): C extends any[] ? never : C;
439
648
  toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
440
649
  };
650
+ /**
651
+ * Lets you group elements without a wrapper node.
652
+ *
653
+ * @see {@link https://react.dev/reference/react/Fragment React Docs}
654
+ *
655
+ * @example
656
+ *
657
+ * ```tsx
658
+ * import { Fragment } from 'react';
659
+ *
660
+ * <Fragment>
661
+ * <td>Hello</td>
662
+ * <td>World</td>
663
+ * </Fragment>
664
+ * ```
665
+ *
666
+ * @example
667
+ *
668
+ * ```tsx
669
+ * // Using the <></> shorthand syntax:
670
+ *
671
+ * <>
672
+ * <td>Hello</td>
673
+ * <td>World</td>
674
+ * </>
675
+ * ```
676
+ */
441
677
  const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
678
+
679
+ /**
680
+ * Lets you find common bugs in your components early during development.
681
+ *
682
+ * @see {@link https://react.dev/reference/react/StrictMode React Docs}
683
+ *
684
+ * @example
685
+ *
686
+ * ```tsx
687
+ * import { StrictMode } from 'react';
688
+ *
689
+ * <StrictMode>
690
+ * <App />
691
+ * </StrictMode>
692
+ * ```
693
+ */
442
694
  const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;
443
695
 
696
+ /**
697
+ * The props accepted by {@link Suspense}.
698
+ *
699
+ * @see {@link https://react.dev/reference/react/Suspense React Docs}
700
+ */
444
701
  interface SuspenseProps {
445
702
  children?: ReactNode | undefined;
446
703
 
@@ -448,27 +705,105 @@ declare namespace React {
448
705
  fallback?: ReactNode;
449
706
  }
450
707
 
708
+ /**
709
+ * Lets you display a fallback until its children have finished loading.
710
+ *
711
+ * @see {@link https://react.dev/reference/react/Suspense React Docs}
712
+ *
713
+ * @example
714
+ *
715
+ * ```tsx
716
+ * import { Suspense } from 'react';
717
+ *
718
+ * <Suspense fallback={<Loading />}>
719
+ * <ProfileDetails />
720
+ * </Suspense>
721
+ * ```
722
+ */
451
723
  const Suspense: ExoticComponent<SuspenseProps>;
452
724
  const version: string;
453
725
 
454
726
  /**
455
- * @see {@link https://react.dev/reference/react/Profiler#onrender-callback Profiler API React Docs}
727
+ * The callback passed to {@link ProfilerProps.onRender}.
728
+ *
729
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
456
730
  */
457
731
  type ProfilerOnRenderCallback = (
732
+ /**
733
+ * The string id prop of the {@link Profiler} tree that has just committed. This lets
734
+ * you identify which part of the tree was committed if you are using multiple
735
+ * profilers.
736
+ *
737
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
738
+ */
458
739
  id: string,
740
+ /**
741
+ * This lets you know whether the tree has just been mounted for the first time
742
+ * or re-rendered due to a change in props, state, or hooks.
743
+ *
744
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
745
+ */
459
746
  phase: "mount" | "update" | "nested-update",
747
+ /**
748
+ * The number of milliseconds spent rendering the {@link Profiler} and its descendants
749
+ * for the current update. This indicates how well the subtree makes use of
750
+ * memoization (e.g. {@link memo} and {@link useMemo}). Ideally this value should decrease
751
+ * significantly after the initial mount as many of the descendants will only need to
752
+ * re-render if their specific props change.
753
+ *
754
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
755
+ */
460
756
  actualDuration: number,
757
+ /**
758
+ * The number of milliseconds estimating how much time it would take to re-render the entire
759
+ * {@link Profiler} subtree without any optimizations. It is calculated by summing up the most
760
+ * recent render durations of each component in the tree. This value estimates a worst-case
761
+ * cost of rendering (e.g. the initial mount or a tree with no memoization). Compare
762
+ * {@link actualDuration} against it to see if memoization is working.
763
+ *
764
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
765
+ */
461
766
  baseDuration: number,
767
+ /**
768
+ * A numeric timestamp for when React began rendering the current update.
769
+ *
770
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
771
+ */
462
772
  startTime: number,
773
+ /**
774
+ * A numeric timestamp for when React committed the current update. This value is shared
775
+ * between all profilers in a commit, enabling them to be grouped if desirable.
776
+ *
777
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
778
+ */
463
779
  commitTime: number,
464
780
  interactions: Set<SchedulerInteraction>,
465
781
  ) => void;
782
+
783
+ /**
784
+ * The props accepted by {@link Profiler}.
785
+ *
786
+ * @see {@link https://react.dev/reference/react/Profiler React Docs}
787
+ */
466
788
  interface ProfilerProps {
467
789
  children?: ReactNode | undefined;
468
790
  id: string;
469
791
  onRender: ProfilerOnRenderCallback;
470
792
  }
471
793
 
794
+ /**
795
+ * Lets you measure rendering performance of a React tree programmatically.
796
+ *
797
+ * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
798
+ *
799
+ * @example
800
+ *
801
+ * ```tsx
802
+ * <Profiler id="App" onRender={onRender}>
803
+ * <App />
804
+ * </Profiler>
805
+ * ```
806
+ */
472
807
  const Profiler: ExoticComponent<ProfilerProps>;
473
808
 
474
809
  //
@@ -499,7 +834,7 @@ declare namespace React {
499
834
  * }
500
835
  * ```
501
836
  *
502
- * @see https://react.dev/reference/react/Component#static-contexttype
837
+ * @see {@link https://react.dev/reference/react/Component#static-contexttype}
503
838
  */
504
839
  static contextType?: Context<any> | undefined;
505
840
 
@@ -516,14 +851,14 @@ declare namespace React {
516
851
  * declare context: React.ContextType<typeof MyContext>
517
852
  * ```
518
853
  *
519
- * @see https://react.dev/reference/react/Component#context
854
+ * @see {@link https://react.dev/reference/react/Component#context}
520
855
  */
521
856
  context: unknown;
522
857
 
523
858
  constructor(props: Readonly<P> | P);
524
859
  /**
525
860
  * @deprecated
526
- * @see https://legacy.reactjs.org/docs/legacy-context.html
861
+ * @see {@link https://legacy.reactjs.org/docs/legacy-context.html}
527
862
  */
528
863
  constructor(props: P, context: any);
529
864
 
@@ -553,6 +888,9 @@ declare namespace React {
553
888
 
554
889
  /**
555
890
  * @deprecated Use `ClassicComponent` from `create-react-class`
891
+ *
892
+ * @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
893
+ * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
556
894
  */
557
895
  interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
558
896
  replaceState(nextState: S, callback?: () => void): void;
@@ -573,9 +911,9 @@ declare namespace React {
573
911
  * receive a type argument that represents the props the component
574
912
  * receives.
575
913
  *
576
- * @typeparam P - The props the component receives.
914
+ * @template P The props the component accepts.
577
915
  * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}
578
- * @alias for {@link React.FunctionComponent}
916
+ * @alias for {@link FunctionComponent}
579
917
  *
580
918
  * @example
581
919
  *
@@ -604,7 +942,7 @@ declare namespace React {
604
942
  * receive a type argument that represents the props the component
605
943
  * accepts.
606
944
  *
607
- * @typeparam P - The props the component accepts.
945
+ * @template P The props the component accepts.
608
946
  * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}
609
947
  *
610
948
  * @example
@@ -719,10 +1057,14 @@ declare namespace React {
719
1057
  type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
720
1058
 
721
1059
  /**
722
- * The type of the function passed to {@link forwardRef}.
1060
+ * The type of the function passed to {@link forwardRef}. This is considered different
1061
+ * to a normal {@link FunctionComponent} because it receives an additional argument,
1062
+ *
1063
+ * @param props Props passed to the component, if any.
1064
+ * @param ref A ref forwarded to the component of type {@link ForwardedRef}.
723
1065
  *
724
- * @typeparam props Props passed to the component, if any.
725
- * @typeparam ref A ref forwarded to the component of type {@link ForwardedRef}.
1066
+ * @template T The type of the forwarded ref.
1067
+ * @template P The type of the props the component accepts.
726
1068
  *
727
1069
  * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}
728
1070
  * @see {@link forwardRef}
@@ -741,14 +1083,14 @@ declare namespace React {
741
1083
  */
742
1084
  displayName?: string | undefined;
743
1085
  /**
744
- * defaultProps are not supported on components passed to forwardRef.
1086
+ * defaultProps are not supported on render functions passed to forwardRef.
745
1087
  *
746
1088
  * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
747
1089
  * @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
748
1090
  */
749
1091
  defaultProps?: never | undefined;
750
1092
  /**
751
- * propTypes are not supported on components passed to forwardRef.
1093
+ * propTypes are not supported on render functions passed to forwardRef.
752
1094
  *
753
1095
  * @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
754
1096
  * @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
@@ -759,8 +1101,8 @@ declare namespace React {
759
1101
  /**
760
1102
  * Represents a component class in React.
761
1103
  *
762
- * @typeparam P The props the component accepts.
763
- * @typeparam S The internal state of the component.
1104
+ * @template P The props the component accepts.
1105
+ * @template S The internal state of the component.
764
1106
  */
765
1107
  interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
766
1108
  new(props: P, context?: any): Component<P, S>;
@@ -825,7 +1167,8 @@ declare namespace React {
825
1167
  *
826
1168
  * An intersection type is used to infer multiple type parameters from
827
1169
  * a single argument, which is useful for many top-level API defs.
828
- * See https://github.com/Microsoft/TypeScript/issues/7234 for more info.
1170
+ * See {@link https://github.com/Microsoft/TypeScript/issues/7234 this GitHub issue}
1171
+ * for more info.
829
1172
  */
830
1173
  type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
831
1174
  & C
@@ -917,8 +1260,8 @@ declare namespace React {
917
1260
  * prevents this from being invoked.
918
1261
  *
919
1262
  * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17
920
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state
921
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
1263
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
1264
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
922
1265
  */
923
1266
  componentWillMount?(): void;
924
1267
  /**
@@ -931,8 +1274,8 @@ declare namespace React {
931
1274
  * prevents this from being invoked.
932
1275
  *
933
1276
  * @deprecated 16.3, use componentDidMount or the constructor instead
934
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state
935
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
1277
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
1278
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
936
1279
  */
937
1280
  UNSAFE_componentWillMount?(): void;
938
1281
  /**
@@ -946,8 +1289,8 @@ declare namespace React {
946
1289
  * prevents this from being invoked.
947
1290
  *
948
1291
  * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17
949
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props
950
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
1292
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1293
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
951
1294
  */
952
1295
  componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
953
1296
  /**
@@ -963,8 +1306,8 @@ declare namespace React {
963
1306
  * prevents this from being invoked.
964
1307
  *
965
1308
  * @deprecated 16.3, use static getDerivedStateFromProps instead
966
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props
967
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
1309
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1310
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
968
1311
  */
969
1312
  UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
970
1313
  /**
@@ -976,8 +1319,8 @@ declare namespace React {
976
1319
  * prevents this from being invoked.
977
1320
  *
978
1321
  * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17
979
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update
980
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
1322
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
1323
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
981
1324
  */
982
1325
  componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
983
1326
  /**
@@ -991,8 +1334,8 @@ declare namespace React {
991
1334
  * prevents this from being invoked.
992
1335
  *
993
1336
  * @deprecated 16.3, use getSnapshotBeforeUpdate instead
994
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update
995
- * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
1337
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
1338
+ * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
996
1339
  */
997
1340
  UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
998
1341
  }
@@ -1031,7 +1374,7 @@ declare namespace React {
1031
1374
  /**
1032
1375
  * The type of the component returned from {@link forwardRef}.
1033
1376
  *
1034
- * @typeparam P The props the component accepts, if any.
1377
+ * @template P The props the component accepts, if any.
1035
1378
  *
1036
1379
  * @see {@link ExoticComponent}
1037
1380
  */
@@ -1041,7 +1384,7 @@ declare namespace React {
1041
1384
  }
1042
1385
 
1043
1386
  /**
1044
- * Lets your component expose a DOM node to parent component
1387
+ * Lets your component expose a DOM node to a parent component
1045
1388
  * using a ref.
1046
1389
  *
1047
1390
  * @see {@link https://react.dev/reference/react/forwardRef React Docs}
@@ -1049,8 +1392,8 @@ declare namespace React {
1049
1392
  *
1050
1393
  * @param render See the {@link ForwardRefRenderFunction}.
1051
1394
  *
1052
- * @typeparam T The type of the DOM node.
1053
- * @typeparam P The props the component accepts, if any.
1395
+ * @template T The type of the DOM node.
1396
+ * @template P The props the component accepts, if any.
1054
1397
  *
1055
1398
  * @example
1056
1399
  *
@@ -1261,14 +1604,14 @@ declare namespace React {
1261
1604
  * context value, as given by the nearest context provider for the given context.
1262
1605
  *
1263
1606
  * @version 16.8.0
1264
- * @see https://react.dev/reference/react/useContext
1607
+ * @see {@link https://react.dev/reference/react/useContext}
1265
1608
  */
1266
1609
  function useContext<T>(context: Context<T> /*, (not public API) observedBits?: number|boolean */): T;
1267
1610
  /**
1268
1611
  * Returns a stateful value, and a function to update it.
1269
1612
  *
1270
1613
  * @version 16.8.0
1271
- * @see https://react.dev/reference/react/useState
1614
+ * @see {@link https://react.dev/reference/react/useState}
1272
1615
  */
1273
1616
  function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
1274
1617
  // convenience overload when first argument is omitted
@@ -1276,7 +1619,7 @@ declare namespace React {
1276
1619
  * Returns a stateful value, and a function to update it.
1277
1620
  *
1278
1621
  * @version 16.8.0
1279
- * @see https://react.dev/reference/react/useState
1622
+ * @see {@link https://react.dev/reference/react/useState}
1280
1623
  */
1281
1624
  function useState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
1282
1625
  /**
@@ -1287,7 +1630,7 @@ declare namespace React {
1287
1630
  * updates because you can pass `dispatch` down instead of callbacks.
1288
1631
  *
1289
1632
  * @version 16.8.0
1290
- * @see https://react.dev/reference/react/useReducer
1633
+ * @see {@link https://react.dev/reference/react/useReducer}
1291
1634
  */
1292
1635
  // overload where dispatch could accept 0 arguments.
1293
1636
  function useReducer<R extends ReducerWithoutAction<any>, I>(
@@ -1303,7 +1646,7 @@ declare namespace React {
1303
1646
  * updates because you can pass `dispatch` down instead of callbacks.
1304
1647
  *
1305
1648
  * @version 16.8.0
1306
- * @see https://react.dev/reference/react/useReducer
1649
+ * @see {@link https://react.dev/reference/react/useReducer}
1307
1650
  */
1308
1651
  // overload where dispatch could accept 0 arguments.
1309
1652
  function useReducer<R extends ReducerWithoutAction<any>>(
@@ -1319,7 +1662,7 @@ declare namespace React {
1319
1662
  * updates because you can pass `dispatch` down instead of callbacks.
1320
1663
  *
1321
1664
  * @version 16.8.0
1322
- * @see https://react.dev/reference/react/useReducer
1665
+ * @see {@link https://react.dev/reference/react/useReducer}
1323
1666
  */
1324
1667
  // overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
1325
1668
  // If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
@@ -1337,7 +1680,7 @@ declare namespace React {
1337
1680
  * updates because you can pass `dispatch` down instead of callbacks.
1338
1681
  *
1339
1682
  * @version 16.8.0
1340
- * @see https://react.dev/reference/react/useReducer
1683
+ * @see {@link https://react.dev/reference/react/useReducer}
1341
1684
  */
1342
1685
  // overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
1343
1686
  function useReducer<R extends Reducer<any, any>, I>(
@@ -1353,7 +1696,7 @@ declare namespace React {
1353
1696
  * updates because you can pass `dispatch` down instead of callbacks.
1354
1697
  *
1355
1698
  * @version 16.8.0
1356
- * @see https://react.dev/reference/react/useReducer
1699
+ * @see {@link https://react.dev/reference/react/useReducer}
1357
1700
  */
1358
1701
 
1359
1702
  // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.
@@ -1378,7 +1721,7 @@ declare namespace React {
1378
1721
  * value around similar to how you’d use instance fields in classes.
1379
1722
  *
1380
1723
  * @version 16.8.0
1381
- * @see https://react.dev/reference/react/useRef
1724
+ * @see {@link https://react.dev/reference/react/useRef}
1382
1725
  */
1383
1726
  function useRef<T>(initialValue: T): MutableRefObject<T>;
1384
1727
  // convenience overload for refs given as a ref prop as they typically start with a null value
@@ -1393,7 +1736,7 @@ declare namespace React {
1393
1736
  * of the generic argument.
1394
1737
  *
1395
1738
  * @version 16.8.0
1396
- * @see https://react.dev/reference/react/useRef
1739
+ * @see {@link https://react.dev/reference/react/useRef}
1397
1740
  */
1398
1741
  function useRef<T>(initialValue: T | null): RefObject<T>;
1399
1742
  // convenience overload for potentially undefined initialValue / call with 0 arguments
@@ -1406,7 +1749,7 @@ declare namespace React {
1406
1749
  * value around similar to how you’d use instance fields in classes.
1407
1750
  *
1408
1751
  * @version 16.8.0
1409
- * @see https://react.dev/reference/react/useRef
1752
+ * @see {@link https://react.dev/reference/react/useRef}
1410
1753
  */
1411
1754
  function useRef<T = undefined>(): MutableRefObject<T | undefined>;
1412
1755
  /**
@@ -1420,7 +1763,7 @@ declare namespace React {
1420
1763
  * `componentDidMount` and `componentDidUpdate`.
1421
1764
  *
1422
1765
  * @version 16.8.0
1423
- * @see https://react.dev/reference/react/useLayoutEffect
1766
+ * @see {@link https://react.dev/reference/react/useLayoutEffect}
1424
1767
  */
1425
1768
  function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;
1426
1769
  /**
@@ -1430,7 +1773,7 @@ declare namespace React {
1430
1773
  * @param deps If present, effect will only activate if the values in the list change.
1431
1774
  *
1432
1775
  * @version 16.8.0
1433
- * @see https://react.dev/reference/react/useEffect
1776
+ * @see {@link https://react.dev/reference/react/useEffect}
1434
1777
  */
1435
1778
  function useEffect(effect: EffectCallback, deps?: DependencyList): void;
1436
1779
  // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref<T>
@@ -1441,7 +1784,7 @@ declare namespace React {
1441
1784
  * `useImperativeHandle` should be used with `React.forwardRef`.
1442
1785
  *
1443
1786
  * @version 16.8.0
1444
- * @see https://react.dev/reference/react/useImperativeHandle
1787
+ * @see {@link https://react.dev/reference/react/useImperativeHandle}
1445
1788
  */
1446
1789
  function useImperativeHandle<T, R extends T>(ref: Ref<T> | undefined, init: () => R, deps?: DependencyList): void;
1447
1790
  // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key
@@ -1451,7 +1794,7 @@ declare namespace React {
1451
1794
  * has changed.
1452
1795
  *
1453
1796
  * @version 16.8.0
1454
- * @see https://react.dev/reference/react/useCallback
1797
+ * @see {@link https://react.dev/reference/react/useCallback}
1455
1798
  */
1456
1799
  // A specific function type would not trigger implicit any.
1457
1800
  // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
@@ -1461,7 +1804,7 @@ declare namespace React {
1461
1804
  * `useMemo` will only recompute the memoized value when one of the `deps` has changed.
1462
1805
  *
1463
1806
  * @version 16.8.0
1464
- * @see https://react.dev/reference/react/useMemo
1807
+ * @see {@link https://react.dev/reference/react/useMemo}
1465
1808
  */
1466
1809
  // allow undefined, but don't make it optional as that is very likely a mistake
1467
1810
  function useMemo<T>(factory: () => T, deps: DependencyList): T;
@@ -1472,7 +1815,7 @@ declare namespace React {
1472
1815
  * It’s most valuable for custom hooks that are part of shared libraries.
1473
1816
  *
1474
1817
  * @version 16.8.0
1475
- * @see https://react.dev/reference/react/useDebugValue
1818
+ * @see {@link https://react.dev/reference/react/useDebugValue}
1476
1819
  */
1477
1820
  // the name of the custom hook is itself derived from the function name at runtime:
1478
1821
  // it's just the function name without the "use" prefix.
@@ -1502,7 +1845,7 @@ declare namespace React {
1502
1845
  *
1503
1846
  * @param value The value that is going to be deferred
1504
1847
  *
1505
- * @see https://react.dev/reference/react/useDeferredValue
1848
+ * @see {@link https://react.dev/reference/react/useDeferredValue}
1506
1849
  */
1507
1850
  export function useDeferredValue<T>(value: T): T;
1508
1851
 
@@ -1519,7 +1862,7 @@ declare namespace React {
1519
1862
  *
1520
1863
  * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
1521
1864
  *
1522
- * @see https://react.dev/reference/react/useTransition
1865
+ * @see {@link https://react.dev/reference/react/useTransition}
1523
1866
  */
1524
1867
  export function useTransition(): [boolean, TransitionStartFunction];
1525
1868
 
@@ -1536,7 +1879,7 @@ declare namespace React {
1536
1879
  * @param effect Imperative function that can return a cleanup function
1537
1880
  * @param deps If present, effect will only activate if the values in the list change.
1538
1881
  *
1539
- * @see https://github.com/facebook/react/pull/21913
1882
+ * @see {@link https://github.com/facebook/react/pull/21913}
1540
1883
  */
1541
1884
  export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void;
1542
1885
 
@@ -1544,7 +1887,7 @@ declare namespace React {
1544
1887
  * @param subscribe
1545
1888
  * @param getSnapshot
1546
1889
  *
1547
- * @see https://github.com/reactwg/react-18/discussions/86
1890
+ * @see {@link https://github.com/reactwg/react-18/discussions/86}
1548
1891
  */
1549
1892
  // keep in sync with `useSyncExternalStore` from `use-sync-external-store`
1550
1893
  export function useSyncExternalStore<Snapshot>(
@@ -2337,12 +2680,12 @@ declare namespace React {
2337
2680
  // Living Standard
2338
2681
  /**
2339
2682
  * Hints at the type of data that might be entered by the user while editing the element or its contents
2340
- * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
2683
+ * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
2341
2684
  */
2342
2685
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
2343
2686
  /**
2344
2687
  * Specify that a standard HTML element should behave like a defined custom built-in element
2345
- * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
2688
+ * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
2346
2689
  */
2347
2690
  is?: string | undefined;
2348
2691
  }
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "18.2.50",
3
+ "version": "18.2.52",
4
4
  "description": "TypeScript definitions for react",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
6
6
  "license": "MIT",
@@ -201,6 +201,6 @@
201
201
  "@types/scheduler": "*",
202
202
  "csstype": "^3.0.2"
203
203
  },
204
- "typesPublisherContentHash": "de06a0c7b26443a49092798af7022732df079fdccd6114cb9ad9dbe3f9d35963",
204
+ "typesPublisherContentHash": "93fc940a3cfa823f1e10e0c4058e113f5fcc839de2adf5b2c9b6046991b0a4e0",
205
205
  "typeScriptVersion": "4.6"
206
206
  }