refactor: prepare types for React 19 (#10746)

This commit is contained in:
Sébastien Lorber 2024-12-06 18:03:04 +01:00 committed by GitHub
parent e9f0641620
commit f9825af43e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
296 changed files with 1105 additions and 915 deletions

View file

@ -13,7 +13,12 @@
* full state object.
*/
declare module '@slorber/react-ideal-image' {
import type {ComponentProps, ComponentType, CSSProperties} from 'react';
import type {
ComponentProps,
ComponentType,
CSSProperties,
ReactNode,
} from 'react';
export type LoadingState = 'initial' | 'loading' | 'loaded' | 'error';
@ -115,5 +120,5 @@ declare module '@slorber/react-ideal-image' {
width: number;
}
export default function IdealImage(props: ImageProps): JSX.Element;
export default function IdealImage(props: ImageProps): ReactNode;
}

View file

@ -52,7 +52,7 @@ declare module '@docusaurus/plugin-ideal-image' {
}
declare module '@theme/IdealImage' {
import type {ComponentProps} from 'react';
import type {ComponentProps, ReactNode} from 'react';
export type SrcType = {
width: number;
@ -72,5 +72,5 @@ declare module '@theme/IdealImage' {
export interface Props extends ComponentProps<'img'> {
readonly img: {default: string} | {src: SrcImage; preSrc: string} | string;
}
export default function IdealImage(props: Props): JSX.Element;
export default function IdealImage(props: Props): ReactNode;
}

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import React, {type ReactNode} from 'react';
import ReactIdealImage, {
type IconKey,
type State,
@ -80,7 +80,7 @@ function getMessage(icon: IconKey, state: State) {
}
}
export default function IdealImage(props: Props): JSX.Element {
export default function IdealImage(props: Props): ReactNode {
const {img, ...propsRest} = props;
// In dev env just use regular img with original file