@types/react 18.2.47 → 18.2.49
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 +295 -28
- react/package.json +2 -2
- react/ts5.0/index.d.ts +2 -1
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:
|
11
|
+
* Last updated: Thu, 01 Feb 2024 06:07:40 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
@@ -371,25 +371,36 @@ declare namespace React {
|
|
371
371
|
children: (value: T) => ReactNode;
|
372
372
|
}
|
373
373
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
374
|
+
/**
|
375
|
+
* An object masquerading as a component. These are created by
|
376
|
+
* {@link forwardRef}, {@link memo}, and {@link createContext}.
|
377
|
+
*
|
378
|
+
* In order to make TypeScript work, we pretend that they are normal
|
379
|
+
* components.
|
380
|
+
*
|
381
|
+
* But they are, in fact, not callable - instead, they are objects which
|
382
|
+
* are treated specially by the renderer.
|
383
|
+
*
|
384
|
+
* @see {@link forwardRef}
|
385
|
+
* @see {@link memo}
|
386
|
+
* @see {@link createContext}
|
387
|
+
*/
|
384
388
|
interface ExoticComponent<P = {}> {
|
385
|
-
/**
|
386
|
-
* **NOTE**: Exotic components are not callable.
|
387
|
-
*/
|
388
389
|
(props: P): ReactNode;
|
389
390
|
readonly $$typeof: symbol;
|
390
391
|
}
|
391
392
|
|
393
|
+
/**
|
394
|
+
* An {@link ExoticComponent} with a `displayName` property applied to it.
|
395
|
+
*/
|
392
396
|
interface NamedExoticComponent<P = {}> extends ExoticComponent<P> {
|
397
|
+
/**
|
398
|
+
* Used in debugging messages. You might want to set it
|
399
|
+
* explicitly if you want to display a different name for
|
400
|
+
* debugging purposes.
|
401
|
+
*
|
402
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname}
|
403
|
+
*/
|
393
404
|
displayName?: string | undefined;
|
394
405
|
}
|
395
406
|
|
@@ -557,23 +568,140 @@ declare namespace React {
|
|
557
568
|
// Class Interfaces
|
558
569
|
// ----------------------------------------------------------------------
|
559
570
|
|
571
|
+
/**
|
572
|
+
* Represents the type of a function component. Can optionally
|
573
|
+
* receive a type argument that represents the props the component
|
574
|
+
* receives.
|
575
|
+
*
|
576
|
+
* @param P - The props the component receives.
|
577
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components}
|
578
|
+
* @alias for {@link React.FunctionComponent}
|
579
|
+
*
|
580
|
+
* @example
|
581
|
+
*
|
582
|
+
* ```tsx
|
583
|
+
* // With props:
|
584
|
+
* type Props = { name: string }
|
585
|
+
*
|
586
|
+
* const MyComponent: FC<Props> = (props) => {
|
587
|
+
* return <div>{props.name}</div>
|
588
|
+
* }
|
589
|
+
* ```
|
590
|
+
*
|
591
|
+
* @example
|
592
|
+
*
|
593
|
+
* ```tsx
|
594
|
+
* // Without props:
|
595
|
+
* const MyComponentWithoutProps: FC = () => {
|
596
|
+
* return <div>MyComponentWithoutProps</div>
|
597
|
+
* }
|
598
|
+
* ```
|
599
|
+
*/
|
560
600
|
type FC<P = {}> = FunctionComponent<P>;
|
561
601
|
|
602
|
+
/**
|
603
|
+
* Represents the type of a function component. Can optionally
|
604
|
+
* receive a type argument that represents the props the component
|
605
|
+
* accepts.
|
606
|
+
*
|
607
|
+
* @param P - The props the component accepts.
|
608
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components}
|
609
|
+
*
|
610
|
+
* @example
|
611
|
+
*
|
612
|
+
* ```tsx
|
613
|
+
* // With props:
|
614
|
+
* type Props = { name: string }
|
615
|
+
*
|
616
|
+
* const MyComponent: FunctionComponent<Props> = (props) => {
|
617
|
+
* return <div>{props.name}</div>
|
618
|
+
* }
|
619
|
+
* ```
|
620
|
+
*
|
621
|
+
* @example
|
622
|
+
*
|
623
|
+
* ```tsx
|
624
|
+
* // Without props:
|
625
|
+
* const MyComponentWithoutProps: FunctionComponent = () => {
|
626
|
+
* return <div>MyComponentWithoutProps</div>
|
627
|
+
* }
|
628
|
+
* ```
|
629
|
+
*/
|
562
630
|
interface FunctionComponent<P = {}> {
|
563
631
|
(props: P, context?: any): ReactNode;
|
632
|
+
/**
|
633
|
+
* Used to declare the types of the props accepted by the
|
634
|
+
* component. These types will be checked during rendering
|
635
|
+
* and in development only.
|
636
|
+
*
|
637
|
+
* We recommend using TypeScript instead of checking prop
|
638
|
+
* types at runtime.
|
639
|
+
*
|
640
|
+
* @see {@link https://react.dev/reference/react/Component#static-proptypes}
|
641
|
+
*/
|
564
642
|
propTypes?: WeakValidationMap<P> | undefined;
|
643
|
+
/**
|
644
|
+
* @deprecated
|
645
|
+
*
|
646
|
+
* Lets you specify which legacy context is consumed by
|
647
|
+
* this component.
|
648
|
+
*
|
649
|
+
* @see {@link https://legacy.reactjs.org/docs/legacy-context.html}
|
650
|
+
*/
|
565
651
|
contextTypes?: ValidationMap<any> | undefined;
|
652
|
+
/**
|
653
|
+
* Used to define default values for the props accepted by
|
654
|
+
* the component.
|
655
|
+
*
|
656
|
+
* @see {@link https://react.dev/reference/react/Component#static-defaultprops}
|
657
|
+
*
|
658
|
+
* @example
|
659
|
+
*
|
660
|
+
* ```tsx
|
661
|
+
* type Props = { name?: string }
|
662
|
+
*
|
663
|
+
* const MyComponent: FC<Props> = (props) => {
|
664
|
+
* return <div>{props.name}</div>
|
665
|
+
* }
|
666
|
+
*
|
667
|
+
* MyComponent.defaultProps = {
|
668
|
+
* name: 'John Doe'
|
669
|
+
* }
|
670
|
+
* ```
|
671
|
+
*/
|
566
672
|
defaultProps?: Partial<P> | undefined;
|
673
|
+
/**
|
674
|
+
* Used in debugging messages. You might want to set it
|
675
|
+
* explicitly if you want to display a different name for
|
676
|
+
* debugging purposes.
|
677
|
+
*
|
678
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname}
|
679
|
+
*
|
680
|
+
* @example
|
681
|
+
*
|
682
|
+
* ```tsx
|
683
|
+
*
|
684
|
+
* const MyComponent: FC = () => {
|
685
|
+
* return <div>Hello!</div>
|
686
|
+
* }
|
687
|
+
*
|
688
|
+
* MyComponent.displayName = 'MyAwesomeComponent'
|
689
|
+
* ```
|
690
|
+
*/
|
567
691
|
displayName?: string | undefined;
|
568
692
|
}
|
569
693
|
|
570
694
|
/**
|
571
|
-
* @deprecated - Equivalent
|
695
|
+
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
696
|
+
*
|
697
|
+
* @see {@link React.FunctionComponent}
|
572
698
|
*/
|
573
699
|
type VFC<P = {}> = VoidFunctionComponent<P>;
|
574
700
|
|
575
701
|
/**
|
576
|
-
* @deprecated - Equivalent
|
702
|
+
* @deprecated - Equivalent to {@link React.FunctionComponent}.
|
703
|
+
*
|
704
|
+
* @see {@link React.FunctionComponent}
|
577
705
|
*/
|
578
706
|
interface VoidFunctionComponent<P = {}> {
|
579
707
|
(props: P, context?: any): ReactNode;
|
@@ -583,19 +711,47 @@ declare namespace React {
|
|
583
711
|
displayName?: string | undefined;
|
584
712
|
}
|
585
713
|
|
714
|
+
/**
|
715
|
+
* The type of the ref received by a {@link ForwardRefRenderFunction}.
|
716
|
+
*
|
717
|
+
* @see {@link ForwardRefRenderFunction}
|
718
|
+
*/
|
586
719
|
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
587
720
|
|
721
|
+
/**
|
722
|
+
* The type of the function passed to {@link forwardRef}.
|
723
|
+
*
|
724
|
+
* @param props Props passed to the component, if any.
|
725
|
+
* @param ref A ref forwarded to the component of type {@link ForwardedRef}.
|
726
|
+
*
|
727
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/}
|
728
|
+
* @see {@link forwardRef}
|
729
|
+
*/
|
588
730
|
interface ForwardRefRenderFunction<T, P = {}> {
|
589
731
|
(props: P, ref: ForwardedRef<T>): ReactNode;
|
732
|
+
/**
|
733
|
+
* Used in debugging messages. You might want to set it
|
734
|
+
* explicitly if you want to display a different name for
|
735
|
+
* debugging purposes.
|
736
|
+
*
|
737
|
+
* Will show `ForwardRef(${Component.displayName || Component.name})`
|
738
|
+
* in devtools by default, but can be given its own specific name.
|
739
|
+
*
|
740
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname}
|
741
|
+
*/
|
590
742
|
displayName?: string | undefined;
|
591
|
-
// explicit rejected with `never` required due to
|
592
|
-
// https://github.com/microsoft/TypeScript/issues/36826
|
593
743
|
/**
|
594
|
-
* defaultProps are not supported on
|
744
|
+
* defaultProps are not supported on components passed to forwardRef.
|
745
|
+
*
|
746
|
+
* @see {@link https://github.com/microsoft/TypeScript/issues/36826} for context
|
747
|
+
* @see {@link https://react.dev/reference/react/Component#static-defaultprops}
|
595
748
|
*/
|
596
749
|
defaultProps?: never | undefined;
|
597
750
|
/**
|
598
|
-
* propTypes are not supported on
|
751
|
+
* propTypes are not supported on components passed to forwardRef.
|
752
|
+
*
|
753
|
+
* @see {@link https://github.com/microsoft/TypeScript/issues/36826} for context
|
754
|
+
* @see {@link https://react.dev/reference/react/Component#static-proptypes}
|
599
755
|
*/
|
600
756
|
propTypes?: never | undefined;
|
601
757
|
}
|
@@ -822,13 +978,45 @@ declare namespace React {
|
|
822
978
|
|
823
979
|
function createRef<T>(): RefObject<T>;
|
824
980
|
|
825
|
-
|
826
|
-
|
981
|
+
/**
|
982
|
+
* The type of the component returned from {@link forwardRef}.
|
983
|
+
*
|
984
|
+
* @typeparam P The props the component accepts, if any.
|
985
|
+
*
|
986
|
+
* @see {@link ExoticComponent}
|
987
|
+
*/
|
827
988
|
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
828
989
|
defaultProps?: Partial<P> | undefined;
|
829
990
|
propTypes?: WeakValidationMap<P> | undefined;
|
830
991
|
}
|
831
992
|
|
993
|
+
/**
|
994
|
+
* Lets your component expose a DOM node to parent component
|
995
|
+
* using a ref.
|
996
|
+
*
|
997
|
+
* @see {@link https://react.dev/reference/react/forwardRef}
|
998
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/}
|
999
|
+
*
|
1000
|
+
* @param render See the {@link ForwardRefRenderFunction}.
|
1001
|
+
*
|
1002
|
+
* @typeparam T The type of the DOM node.
|
1003
|
+
* @typeparam P The props the component accepts, if any.
|
1004
|
+
*
|
1005
|
+
* @example
|
1006
|
+
*
|
1007
|
+
* ```tsx
|
1008
|
+
* interface Props {
|
1009
|
+
* children?: ReactNode;
|
1010
|
+
* type: "submit" | "button";
|
1011
|
+
* }
|
1012
|
+
*
|
1013
|
+
* export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
|
1014
|
+
* <button ref={ref} className="MyClassName" type={props.type}>
|
1015
|
+
* {props.children}
|
1016
|
+
* </button>
|
1017
|
+
* ));
|
1018
|
+
* ```
|
1019
|
+
*/
|
832
1020
|
function forwardRef<T, P = {}>(
|
833
1021
|
render: ForwardRefRenderFunction<T, P>,
|
834
1022
|
): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
@@ -852,28 +1040,107 @@ declare namespace React {
|
|
852
1040
|
type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
|
853
1041
|
|
854
1042
|
/**
|
855
|
-
*
|
856
|
-
*
|
1043
|
+
* Used to retrieve the props a component accepts. Can either be passed a string,
|
1044
|
+
* indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React
|
1045
|
+
* component.
|
1046
|
+
*
|
1047
|
+
* It's usually better to use {@link ComponentPropsWithRef} or {@link ComponentPropsWithoutRef}
|
1048
|
+
* instead of this type, as they let you be explicit about whether or not to include
|
1049
|
+
* the `ref` prop.
|
1050
|
+
*
|
1051
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/}
|
1052
|
+
*
|
1053
|
+
* @example
|
1054
|
+
*
|
1055
|
+
* ```tsx
|
1056
|
+
* // Retrieves the props an 'input' element accepts
|
1057
|
+
* type InputProps = React.ComponentProps<'input'>;
|
1058
|
+
* ```
|
1059
|
+
*
|
1060
|
+
* @example
|
1061
|
+
*
|
1062
|
+
* ```tsx
|
1063
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1064
|
+
*
|
1065
|
+
* // Retrieves the props 'MyComponent' accepts
|
1066
|
+
* type MyComponentProps = React.ComponentProps<typeof MyComponent>;
|
1067
|
+
* ```
|
857
1068
|
*/
|
858
1069
|
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
859
1070
|
JSXElementConstructor<infer P> ? P
|
860
1071
|
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
861
1072
|
: {};
|
1073
|
+
|
862
1074
|
/**
|
863
|
-
*
|
1075
|
+
* Used to retrieve the props a component accepts with its ref. Can either be
|
1076
|
+
* passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the
|
1077
|
+
* type of a React component.
|
1078
|
+
*
|
1079
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/}
|
864
1080
|
*
|
865
|
-
*
|
1081
|
+
* @example
|
1082
|
+
*
|
1083
|
+
* ```tsx
|
1084
|
+
* // Retrieves the props an 'input' element accepts
|
1085
|
+
* type InputProps = React.ComponentPropsWithRef<'input'>;
|
1086
|
+
* ```
|
1087
|
+
*
|
1088
|
+
* @example
|
1089
|
+
*
|
1090
|
+
* ```tsx
|
1091
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1092
|
+
*
|
1093
|
+
* // Retrieves the props 'MyComponent' accepts
|
1094
|
+
* type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
|
1095
|
+
* ```
|
866
1096
|
*/
|
867
1097
|
type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
|
868
1098
|
? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
|
869
1099
|
: PropsWithRef<ComponentProps<T>>;
|
870
1100
|
/**
|
871
|
-
*
|
1101
|
+
* Used to retrieve the props a custom component accepts with its ref.
|
1102
|
+
*
|
1103
|
+
* Unlike {@link ComponentPropsWithRef}, this only works with custom
|
1104
|
+
* components, i.e. components you define yourself. This is to improve
|
1105
|
+
* type-checking performance.
|
1106
|
+
*
|
1107
|
+
* @example
|
1108
|
+
*
|
1109
|
+
* ```tsx
|
1110
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1111
|
+
*
|
1112
|
+
* // Retrieves the props 'MyComponent' accepts
|
1113
|
+
* type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
|
1114
|
+
* ```
|
872
1115
|
*/
|
873
1116
|
type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
|
874
1117
|
? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
|
875
1118
|
: T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
|
876
1119
|
: never;
|
1120
|
+
|
1121
|
+
/**
|
1122
|
+
* Used to retrieve the props a component accepts without its ref. Can either be
|
1123
|
+
* passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the
|
1124
|
+
* type of a React component.
|
1125
|
+
*
|
1126
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/}
|
1127
|
+
*
|
1128
|
+
* @example
|
1129
|
+
*
|
1130
|
+
* ```tsx
|
1131
|
+
* // Retrieves the props an 'input' element accepts
|
1132
|
+
* type InputProps = React.ComponentPropsWithoutRef<'input'>;
|
1133
|
+
* ```
|
1134
|
+
*
|
1135
|
+
* @example
|
1136
|
+
*
|
1137
|
+
* ```tsx
|
1138
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1139
|
+
*
|
1140
|
+
* // Retrieves the props 'MyComponent' accepts
|
1141
|
+
* type MyComponentPropsWithoutRef = React.ComponentPropsWithoutRef<typeof MyComponent>;
|
1142
|
+
* ```
|
1143
|
+
*/
|
877
1144
|
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
878
1145
|
|
879
1146
|
type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
|
@@ -2456,10 +2723,10 @@ declare namespace React {
|
|
2456
2723
|
|
2457
2724
|
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
2458
2725
|
charSet?: string | undefined;
|
2726
|
+
content?: string | undefined;
|
2459
2727
|
httpEquiv?: string | undefined;
|
2460
|
-
name?: string | undefined;
|
2461
2728
|
media?: string | undefined;
|
2462
|
-
|
2729
|
+
name?: string | undefined;
|
2463
2730
|
}
|
2464
2731
|
|
2465
2732
|
interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
|
react/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react",
|
3
|
-
"version": "18.2.
|
3
|
+
"version": "18.2.49",
|
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": "0eb7a991a00ce343b222b32fb0879928350f9dd65227c90a49a1d8ceccf4a389",
|
205
205
|
"typeScriptVersion": "4.6"
|
206
206
|
}
|
react/ts5.0/index.d.ts
CHANGED
@@ -2458,9 +2458,10 @@ declare namespace React {
|
|
2458
2458
|
|
2459
2459
|
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
2460
2460
|
charSet?: string | undefined;
|
2461
|
+
content?: string | undefined;
|
2461
2462
|
httpEquiv?: string | undefined;
|
2462
|
-
name?: string | undefined;
|
2463
2463
|
media?: string | undefined;
|
2464
|
+
name?: string | undefined;
|
2464
2465
|
}
|
2465
2466
|
|
2466
2467
|
interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
|