Skip to content

Commit 2e6fcbc

Browse files
committed
chore: just a tiny bit of a type improvement
1 parent 0647ee3 commit 2e6fcbc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

apps/site/components/Common/CodeBox/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use client';
22

33
import {
4-
DocumentDuplicateIcon,
54
CodeBracketIcon,
5+
DocumentDuplicateIcon,
66
} from '@heroicons/react/24/outline';
77
import classNames from 'classnames';
88
import { useTranslations } from 'next-intl';
9-
import type { FC, PropsWithChildren, ReactElement, ReactNode } from 'react';
9+
import type { FC, PropsWithChildren, ReactElement } from 'react';
1010
import { Fragment, isValidElement, useRef } from 'react';
1111

1212
import Button from '@/components/Common/Button';
@@ -16,10 +16,10 @@ import styles from './index.module.css';
1616

1717
// Transforms a code element with plain text content into a more structured
1818
// format for rendering with line numbers
19-
const transformCode = (
20-
code: ReactElement<PropsWithChildren>,
19+
const transformCode = <T extends ReactElement<PropsWithChildren>>(
20+
code: T,
2121
language: string
22-
): ReactNode => {
22+
): ReactElement<HTMLElement> | T => {
2323
if (!isValidElement(code)) {
2424
// Early return when the `CodeBox` child is not a valid element since the
2525
// type is a ReactNode, and can assume any value

0 commit comments

Comments
 (0)