@types/react 18.2.50 → 18.2.51
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 +244 -17
- 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
|
11
|
+
* Last updated: Thu, 01 Feb 2024 10:06:59 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
@@ -372,18 +372,14 @@ declare namespace React {
|
|
372
372
|
}
|
373
373
|
|
374
374
|
/**
|
375
|
-
* An object masquerading as a component. These are created by
|
376
|
-
* {@link forwardRef}, {@link memo}, and {@link createContext}.
|
375
|
+
* An object masquerading as a component. These are created by functions
|
376
|
+
* like {@link forwardRef}, {@link memo}, and {@link createContext}.
|
377
377
|
*
|
378
378
|
* In order to make TypeScript work, we pretend that they are normal
|
379
379
|
* components.
|
380
380
|
*
|
381
381
|
* But they are, in fact, not callable - instead, they are objects which
|
382
382
|
* are treated specially by the renderer.
|
383
|
-
*
|
384
|
-
* @see {@link forwardRef}
|
385
|
-
* @see {@link memo}
|
386
|
-
* @see {@link createContext}
|
387
383
|
*/
|
388
384
|
interface ExoticComponent<P = {}> {
|
389
385
|
(props: P): ReactNode;
|
@@ -404,24 +400,122 @@ declare namespace React {
|
|
404
400
|
displayName?: string | undefined;
|
405
401
|
}
|
406
402
|
|
403
|
+
/**
|
404
|
+
* An {@link ExoticComponent} with a `propTypes` property applied to it.
|
405
|
+
*/
|
407
406
|
interface ProviderExoticComponent<P> extends ExoticComponent<P> {
|
408
407
|
propTypes?: WeakValidationMap<P> | undefined;
|
409
408
|
}
|
410
409
|
|
410
|
+
/**
|
411
|
+
* Used to retrieve the type of a context object from a {@link Context}.
|
412
|
+
*
|
413
|
+
* @example
|
414
|
+
*
|
415
|
+
* ```tsx
|
416
|
+
* import { createContext } from 'react';
|
417
|
+
*
|
418
|
+
* const MyContext = createContext({ foo: 'bar' });
|
419
|
+
*
|
420
|
+
* type ContextType = ContextType<typeof MyContext>;
|
421
|
+
* // ContextType = { foo: string }
|
422
|
+
* ```
|
423
|
+
*/
|
411
424
|
type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
|
412
425
|
|
413
|
-
|
414
|
-
|
426
|
+
/**
|
427
|
+
* Wraps your components to specify the value of this context for all components inside.
|
428
|
+
*
|
429
|
+
* @see {@link https://react.dev/reference/react/createContext#provider React Docs}
|
430
|
+
*
|
431
|
+
* @example
|
432
|
+
*
|
433
|
+
* ```tsx
|
434
|
+
* import { createContext } from 'react';
|
435
|
+
*
|
436
|
+
* const ThemeContext = createContext('light');
|
437
|
+
*
|
438
|
+
* function App() {
|
439
|
+
* return (
|
440
|
+
* <ThemeContext.Provider value="dark">
|
441
|
+
* <Toolbar />
|
442
|
+
* </ThemeContext.Provider>
|
443
|
+
* );
|
444
|
+
* }
|
445
|
+
* ```
|
446
|
+
*/
|
415
447
|
type Provider<T> = ProviderExoticComponent<ProviderProps<T>>;
|
448
|
+
|
449
|
+
/**
|
450
|
+
* The old way to read context, before {@link useContext} existed.
|
451
|
+
*
|
452
|
+
* @see {@link https://react.dev/reference/react/createContext#consumer React Docs}
|
453
|
+
*
|
454
|
+
* @example
|
455
|
+
*
|
456
|
+
* ```tsx
|
457
|
+
* import { UserContext } from './user-context';
|
458
|
+
*
|
459
|
+
* function Avatar() {
|
460
|
+
* return (
|
461
|
+
* <UserContext.Consumer>
|
462
|
+
* {user => <img src={user.profileImage} alt={user.name} />}
|
463
|
+
* </UserContext.Consumer>
|
464
|
+
* );
|
465
|
+
* }
|
466
|
+
* ```
|
467
|
+
*/
|
416
468
|
type Consumer<T> = ExoticComponent<ConsumerProps<T>>;
|
469
|
+
|
470
|
+
/**
|
471
|
+
* Context lets components pass information deep down without explicitly
|
472
|
+
* passing props.
|
473
|
+
*
|
474
|
+
* Created from {@link createContext}
|
475
|
+
*
|
476
|
+
* @see {@link https://react.dev/learn/passing-data-deeply-with-context React Docs}
|
477
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
|
478
|
+
*
|
479
|
+
* @example
|
480
|
+
*
|
481
|
+
* ```tsx
|
482
|
+
* import { createContext } from 'react';
|
483
|
+
*
|
484
|
+
* const ThemeContext = createContext('light');
|
485
|
+
* ```
|
486
|
+
*/
|
417
487
|
interface Context<T> {
|
418
488
|
Provider: Provider<T>;
|
419
489
|
Consumer: Consumer<T>;
|
490
|
+
/**
|
491
|
+
* Used in debugging messages. You might want to set it
|
492
|
+
* explicitly if you want to display a different name for
|
493
|
+
* debugging purposes.
|
494
|
+
*
|
495
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
|
496
|
+
*/
|
420
497
|
displayName?: string | undefined;
|
421
498
|
}
|
499
|
+
|
500
|
+
/**
|
501
|
+
* Lets you create a {@link Context} that components can provide or read.
|
502
|
+
*
|
503
|
+
* @param defaultValue The value you want the context to have when there is no matching
|
504
|
+
* {@link Provider} in the tree above the component reading the context. This is meant
|
505
|
+
* as a "last resort" fallback.
|
506
|
+
*
|
507
|
+
* @see {@link https://react.dev/reference/react/createContext#reference React Docs}
|
508
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
|
509
|
+
*
|
510
|
+
* @example
|
511
|
+
*
|
512
|
+
* ```tsx
|
513
|
+
* import { createContext } from 'react';
|
514
|
+
*
|
515
|
+
* const ThemeContext = createContext('light');
|
516
|
+
* ```
|
517
|
+
*/
|
422
518
|
function createContext<T>(
|
423
|
-
// If you thought this should be optional, see
|
424
|
-
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106
|
425
519
|
defaultValue: T,
|
426
520
|
): Context<T>;
|
427
521
|
|
@@ -438,9 +532,57 @@ declare namespace React {
|
|
438
532
|
only<C>(children: C): C extends any[] ? never : C;
|
439
533
|
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
440
534
|
};
|
535
|
+
/**
|
536
|
+
* Lets you group elements without a wrapper node.
|
537
|
+
*
|
538
|
+
* @see {@link https://react.dev/reference/react/Fragment React Docs}
|
539
|
+
*
|
540
|
+
* @example
|
541
|
+
*
|
542
|
+
* ```tsx
|
543
|
+
* import { Fragment } from 'react';
|
544
|
+
*
|
545
|
+
* <Fragment>
|
546
|
+
* <td>Hello</td>
|
547
|
+
* <td>World</td>
|
548
|
+
* </Fragment>
|
549
|
+
* ```
|
550
|
+
*
|
551
|
+
* @example
|
552
|
+
*
|
553
|
+
* ```tsx
|
554
|
+
* // Using the <></> shorthand syntax:
|
555
|
+
*
|
556
|
+
* <>
|
557
|
+
* <td>Hello</td>
|
558
|
+
* <td>World</td>
|
559
|
+
* </>
|
560
|
+
* ```
|
561
|
+
*/
|
441
562
|
const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
|
563
|
+
|
564
|
+
/**
|
565
|
+
* Lets you find common bugs in your components early during development.
|
566
|
+
*
|
567
|
+
* @see {@link https://react.dev/reference/react/StrictMode React Docs}
|
568
|
+
*
|
569
|
+
* @example
|
570
|
+
*
|
571
|
+
* ```tsx
|
572
|
+
* import { StrictMode } from 'react';
|
573
|
+
*
|
574
|
+
* <StrictMode>
|
575
|
+
* <App />
|
576
|
+
* </StrictMode>
|
577
|
+
* ```
|
578
|
+
*/
|
442
579
|
const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;
|
443
580
|
|
581
|
+
/**
|
582
|
+
* The props accepted by {@link Suspense}.
|
583
|
+
*
|
584
|
+
* @see {@link https://react.dev/reference/react/Suspense React Docs}
|
585
|
+
*/
|
444
586
|
interface SuspenseProps {
|
445
587
|
children?: ReactNode | undefined;
|
446
588
|
|
@@ -448,27 +590,105 @@ declare namespace React {
|
|
448
590
|
fallback?: ReactNode;
|
449
591
|
}
|
450
592
|
|
593
|
+
/**
|
594
|
+
* Lets you display a fallback until its children have finished loading.
|
595
|
+
*
|
596
|
+
* @see {@link https://react.dev/reference/react/Suspense React Docs}
|
597
|
+
*
|
598
|
+
* @example
|
599
|
+
*
|
600
|
+
* ```tsx
|
601
|
+
* import { Suspense } from 'react';
|
602
|
+
*
|
603
|
+
* <Suspense fallback={<Loading />}>
|
604
|
+
* <ProfileDetails />
|
605
|
+
* </Suspense>
|
606
|
+
* ```
|
607
|
+
*/
|
451
608
|
const Suspense: ExoticComponent<SuspenseProps>;
|
452
609
|
const version: string;
|
453
610
|
|
454
611
|
/**
|
455
|
-
*
|
612
|
+
* The callback passed to {@link ProfilerProps.onRender}.
|
613
|
+
*
|
614
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
456
615
|
*/
|
457
616
|
type ProfilerOnRenderCallback = (
|
617
|
+
/**
|
618
|
+
* The string id prop of the {@link Profiler} tree that has just committed. This lets
|
619
|
+
* you identify which part of the tree was committed if you are using multiple
|
620
|
+
* profilers.
|
621
|
+
*
|
622
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
623
|
+
*/
|
458
624
|
id: string,
|
625
|
+
/**
|
626
|
+
* This lets you know whether the tree has just been mounted for the first time
|
627
|
+
* or re-rendered due to a change in props, state, or hooks.
|
628
|
+
*
|
629
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
630
|
+
*/
|
459
631
|
phase: "mount" | "update" | "nested-update",
|
632
|
+
/**
|
633
|
+
* The number of milliseconds spent rendering the {@link Profiler} and its descendants
|
634
|
+
* for the current update. This indicates how well the subtree makes use of
|
635
|
+
* memoization (e.g. {@link memo} and {@link useMemo}). Ideally this value should decrease
|
636
|
+
* significantly after the initial mount as many of the descendants will only need to
|
637
|
+
* re-render if their specific props change.
|
638
|
+
*
|
639
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
640
|
+
*/
|
460
641
|
actualDuration: number,
|
642
|
+
/**
|
643
|
+
* The number of milliseconds estimating how much time it would take to re-render the entire
|
644
|
+
* {@link Profiler} subtree without any optimizations. It is calculated by summing up the most
|
645
|
+
* recent render durations of each component in the tree. This value estimates a worst-case
|
646
|
+
* cost of rendering (e.g. the initial mount or a tree with no memoization). Compare
|
647
|
+
* {@link actualDuration} against it to see if memoization is working.
|
648
|
+
*
|
649
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
650
|
+
*/
|
461
651
|
baseDuration: number,
|
652
|
+
/**
|
653
|
+
* A numeric timestamp for when React began rendering the current update.
|
654
|
+
*
|
655
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
656
|
+
*/
|
462
657
|
startTime: number,
|
658
|
+
/**
|
659
|
+
* A numeric timestamp for when React committed the current update. This value is shared
|
660
|
+
* between all profilers in a commit, enabling them to be grouped if desirable.
|
661
|
+
*
|
662
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
663
|
+
*/
|
463
664
|
commitTime: number,
|
464
665
|
interactions: Set<SchedulerInteraction>,
|
465
666
|
) => void;
|
667
|
+
|
668
|
+
/**
|
669
|
+
* The props accepted by {@link Profiler}.
|
670
|
+
*
|
671
|
+
* @see {@link https://react.dev/reference/react/Profiler React Docs}
|
672
|
+
*/
|
466
673
|
interface ProfilerProps {
|
467
674
|
children?: ReactNode | undefined;
|
468
675
|
id: string;
|
469
676
|
onRender: ProfilerOnRenderCallback;
|
470
677
|
}
|
471
678
|
|
679
|
+
/**
|
680
|
+
* Lets you measure rendering performance of a React tree programmatically.
|
681
|
+
*
|
682
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
683
|
+
*
|
684
|
+
* @example
|
685
|
+
*
|
686
|
+
* ```tsx
|
687
|
+
* <Profiler id="App" onRender={onRender}>
|
688
|
+
* <App />
|
689
|
+
* </Profiler>
|
690
|
+
* ```
|
691
|
+
*/
|
472
692
|
const Profiler: ExoticComponent<ProfilerProps>;
|
473
693
|
|
474
694
|
//
|
@@ -553,6 +773,9 @@ declare namespace React {
|
|
553
773
|
|
554
774
|
/**
|
555
775
|
* @deprecated Use `ClassicComponent` from `create-react-class`
|
776
|
+
*
|
777
|
+
* @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
|
778
|
+
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
556
779
|
*/
|
557
780
|
interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
|
558
781
|
replaceState(nextState: S, callback?: () => void): void;
|
@@ -719,10 +942,14 @@ declare namespace React {
|
|
719
942
|
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
720
943
|
|
721
944
|
/**
|
722
|
-
* The type of the function passed to {@link forwardRef}.
|
945
|
+
* The type of the function passed to {@link forwardRef}. This is considered different
|
946
|
+
* to a normal {@link FunctionComponent} because it receives an additional argument,
|
947
|
+
*
|
948
|
+
* @param props Props passed to the component, if any.
|
949
|
+
* @param ref A ref forwarded to the component of type {@link ForwardedRef}.
|
723
950
|
*
|
724
|
-
* @typeparam
|
725
|
-
* @typeparam
|
951
|
+
* @typeparam T The type of the forwarded ref.
|
952
|
+
* @typeparam P The type of the props the component accepts.
|
726
953
|
*
|
727
954
|
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}
|
728
955
|
* @see {@link forwardRef}
|
@@ -741,14 +968,14 @@ declare namespace React {
|
|
741
968
|
*/
|
742
969
|
displayName?: string | undefined;
|
743
970
|
/**
|
744
|
-
* defaultProps are not supported on
|
971
|
+
* defaultProps are not supported on render functions passed to forwardRef.
|
745
972
|
*
|
746
973
|
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
747
974
|
* @see {@link https://react.dev/reference/react/Component#static-defaultprops React Docs}
|
748
975
|
*/
|
749
976
|
defaultProps?: never | undefined;
|
750
977
|
/**
|
751
|
-
* propTypes are not supported on
|
978
|
+
* propTypes are not supported on render functions passed to forwardRef.
|
752
979
|
*
|
753
980
|
* @see {@link https://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue} for context
|
754
981
|
* @see {@link https://react.dev/reference/react/Component#static-proptypes React Docs}
|
@@ -1041,7 +1268,7 @@ declare namespace React {
|
|
1041
1268
|
}
|
1042
1269
|
|
1043
1270
|
/**
|
1044
|
-
* Lets your component expose a DOM node to parent component
|
1271
|
+
* Lets your component expose a DOM node to a parent component
|
1045
1272
|
* using a ref.
|
1046
1273
|
*
|
1047
1274
|
* @see {@link https://react.dev/reference/react/forwardRef React Docs}
|
react/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react",
|
3
|
-
"version": "18.2.
|
3
|
+
"version": "18.2.51",
|
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": "
|
204
|
+
"typesPublisherContentHash": "d210a53ee59001ed347fd48af226f2e1968d4c348de7f3b360d5e450f4e1b70f",
|
205
205
|
"typeScriptVersion": "4.6"
|
206
206
|
}
|