From 9be32b79997b0acdb82d4561c2b3d3b51f6b0926 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Tue, 1 Sep 2026 14:53:29 -0700 Subject: [PATCH] chore(typescript): enable strict mode --- .../global/BestPracticeFigure/index.tsx | 10 +- src/components/global/Codepen/index.tsx | 10 +- src/components/global/DocsCard/index.tsx | 3 +- src/components/global/DocsCards/index.tsx | 2 +- src/components/global/Playground/index.tsx | 126 +++++++++++------- .../global/Playground/playground.types.ts | 30 +++++ .../global/PlaygroundTabs/index.tsx | 54 ++++---- .../PlaygroundTabs/playgroundTabs.types.ts | 20 +++ src/components/page/api/APIList/index.tsx | 4 +- .../page/api/EncapsulationPill/index.tsx | 2 +- src/components/page/intro/AppWizard/index.tsx | 4 +- .../page/native/DocsButton/index.tsx | 11 +- .../native/NativeEnterpriseCard/index.tsx | 4 +- .../page/react/PageStyles/index.tsx | 4 +- .../page/theming/CodeColor/index.tsx | 4 +- .../page/theming/ColorAccordion/index.tsx | 23 ++-- .../page/theming/ColorDot/index.tsx | 4 +- .../page/theming/ColorGenerator/index.tsx | 13 +- .../page/theming/ColorInput/index.tsx | 8 +- .../theming/LayeredColorsSelect/index.tsx | 27 +++- .../theming/SteppedColorGenerator/index.tsx | 4 +- .../page/theming/_utils/color-variables.ts | 6 + src/components/page/theming/_utils/color.ts | 4 +- src/components/page/theming/_utils/index.tsx | 4 +- src/theme/MDXComponents/Table.tsx | 16 ++- tsconfig.json | 3 +- 26 files changed, 274 insertions(+), 126 deletions(-) create mode 100644 src/components/global/PlaygroundTabs/playgroundTabs.types.ts diff --git a/src/components/global/BestPracticeFigure/index.tsx b/src/components/global/BestPracticeFigure/index.tsx index b0254eca824..cc024dca957 100644 --- a/src/components/global/BestPracticeFigure/index.tsx +++ b/src/components/global/BestPracticeFigure/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { type ReactNode } from 'react'; import './best-practice-figure.css'; @@ -54,6 +54,14 @@ export default function BestPracticeFigure({ doImage, doNotImage, cautionImage, +}: { + text: ReactNode; + doText: ReactNode; + doNotText?: ReactNode; + cautionText?: ReactNode; + doImage: ReactNode; + doNotImage?: ReactNode; + cautionImage?: ReactNode; }) { return (
diff --git a/src/components/global/Codepen/index.tsx b/src/components/global/Codepen/index.tsx index 8b7b8854da9..9b33ed7f262 100644 --- a/src/components/global/Codepen/index.tsx +++ b/src/components/global/Codepen/index.tsx @@ -2,7 +2,15 @@ import React, { type ReactNode } from 'react'; import { useScript } from '@site/src/utils/hooks'; -function CodePen(props): ReactNode { +function CodePen(props: { + height?: number | string; + theme?: string; + defaultTab?: string; + user?: string; + slug?: string; + preview?: boolean; + penTitle?: string; +}): ReactNode { const status = useScript('https://static.codepen.io/assets/embed/ei.js'); // console.log('test',status, props) return ( diff --git a/src/components/global/DocsCard/index.tsx b/src/components/global/DocsCard/index.tsx index 0e191ae6618..fac87607abe 100644 --- a/src/components/global/DocsCard/index.tsx +++ b/src/components/global/DocsCard/index.tsx @@ -53,11 +53,10 @@ function DocsCard(props: Props): ReactNode { ); - const className = clsx({ + const className = clsx(props.className, { 'Card-with-image': typeof props.img !== 'undefined', 'Card-without-image': typeof props.img === 'undefined', 'Card-size-lg': props.size === 'lg', - [props.className]: props.className, }); if (isStatic) { diff --git a/src/components/global/DocsCards/index.tsx b/src/components/global/DocsCards/index.tsx index ea2d310e791..1f040dc8148 100644 --- a/src/components/global/DocsCards/index.tsx +++ b/src/components/global/DocsCards/index.tsx @@ -2,7 +2,7 @@ import React, { type ReactNode } from 'react'; import './cards.css'; -function DocsCards(props): ReactNode { +function DocsCards(props: { className?: string; children?: ReactNode }): ReactNode { return {props.children}; } diff --git a/src/components/global/Playground/index.tsx b/src/components/global/Playground/index.tsx index e47a69075ca..b5c117ffc84 100644 --- a/src/components/global/Playground/index.tsx +++ b/src/components/global/Playground/index.tsx @@ -1,10 +1,19 @@ -import React, { RefObject, forwardRef, useEffect, useMemo, useRef, useState } from 'react'; +import React, { + ForwardedRef, + type ReactElement, + type ReactNode, + forwardRef, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; import useBaseUrl from '@docusaurus/useBaseUrl'; import './playground.css'; import { EditorOptions, openAngularEditor, openHtmlEditor, openReactEditor, openVueEditor } from './stackblitz.utils'; import { useColorMode } from '@docusaurus/theme-common'; -import { ConsoleItem, Mode, UsageTarget } from './playground.types'; +import { CodeSnippets, ConsoleItem, Mode, UsageTarget } from './playground.types'; import Tooltip from '../Tooltip'; import PlaygroundTabs from '../PlaygroundTabs'; @@ -30,7 +39,7 @@ const ControlButton = forwardRef( label: string; disabled?: boolean; }, - ref: RefObject + ref: ForwardedRef ) => { const controlButton = (