fix type errors

This commit is contained in:
sebastien 2024-12-06 18:38:23 +01:00
parent 20fd0afc0e
commit ca7ef20d06
4 changed files with 4 additions and 5 deletions

View file

@ -11,7 +11,7 @@ import {useMutationObserver} from './useMutationObserver';
// Callback fires when the "hidden" attribute of a tabpanel changes
// See https://github.com/facebook/docusaurus/pull/7485
function useTabBecameVisibleCallback(
codeBlockRef: RefObject<HTMLPreElement>,
codeBlockRef: RefObject<HTMLPreElement | null>,
callback: () => void,
) {
const [hiddenTabElement, setHiddenTabElement] = useState<
@ -53,7 +53,7 @@ function useTabBecameVisibleCallback(
}
export function useCodeWordWrap(): {
readonly codeBlockRef: RefObject<HTMLPreElement>;
readonly codeBlockRef: RefObject<HTMLPreElement | null>;
readonly isEnabled: boolean;
readonly isCodeScrollable: boolean;
readonly toggle: () => void;

View file

@ -44,7 +44,7 @@ export function useEvent<T extends (...args: never[]) => unknown>(
* Gets `value` from the last render.
*/
export function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>();
const ref = useRef<T>(undefined);
useIsomorphicLayoutEffect(() => {
ref.current = value;

View file

@ -52,7 +52,7 @@ function useSkipToContent(): {
* so that keyboard navigators can instantly interact with the link and jump
* to content.
*/
containerRef: React.RefObject<HTMLDivElement>;
containerRef: React.RefObject<HTMLDivElement | null>;
/**
* Callback fired when the skip to content link has been clicked.
* It will programmatically focus the main content.

View file

@ -199,7 +199,6 @@ function DocSearch({
})),
).current;
// @ts-expect-error: TODO fix lib issue after React 19, using JSX.Element
const resultsFooterComponent: DocSearchProps['resultsFooterComponent'] =
useMemo(
() =>