An open source design system that's fully customizable and agent ready
TypeScript
fix(docsite): add react/jsx-runtime types to playground Monaco (#2481)
Cindy Zhang3c2b22d460df
diff --git a/apps/docsite/scripts/generate-playground-types.mjs b/apps/docsite/scripts/generate-playground-types.mjsindex 465c63d434..93393b7564 100644--- a/apps/docsite/scripts/generate-playground-types.mjs+++ b/apps/docsite/scripts/generate-playground-types.mjs@@ -51,6 +51,23 @@ const xdsTypes = collectDts(distDir);const fileCount = Object.keys(xdsTypes).length;// Also generate a minimal React types stub+const reactJsxRuntimeTypes = `+declare module 'react/jsx-runtime' {+ export namespace JSX {+ type Element = any;+ interface IntrinsicElements {+ [elemName: string]: any;+ }+ interface ElementChildrenAttribute {+ children: {};+ }+ }+ export function jsx(type: any, props: any, key?: string): JSX.Element;+ export function jsxs(type: any, props: any, key?: string): JSX.Element;+ export const Fragment: any;+}+`;+const reactTypes = `declare module 'react' {export type ReactNode = any;@@ -128,7 +145,7 @@ declare module '@stylexjs/stylex' {const output = {'@xds/core': xdsTypes,- react: {'index.d.ts': reactTypes},+ react: {'index.d.ts': reactTypes, 'jsx-runtime.d.ts': reactJsxRuntimeTypes},'@stylexjs/stylex': {'index.d.ts': stylexTypes},};diff --git a/apps/docsite/src/app/playground/PlaygroundClient.tsx b/apps/docsite/src/app/playground/PlaygroundClient.tsxindex 8f945908f4..0f5f7ca902 100644--- a/apps/docsite/src/app/playground/PlaygroundClient.tsx+++ b/apps/docsite/src/app/playground/PlaygroundClient.tsx@@ -118,15 +118,17 @@ export default function Demo() {const [count, setCount] = useState(0);return (- <XDSCard padding={5} maxWidth={400}>- <XDSVStack gap={12}>- <XDSHeading level={3}>- XDS Playground- </XDSHeading>- <XDSText color="secondary">- Edit the code and see live changes.- </XDSText>- <XDSHStack gap={8} align="center">+ <XDSCard maxWidth={400}>+ <XDSVStack gap={4}>+ <XDSVStack>+ <XDSHeading level={3}>+ XDS Playground+ </XDSHeading>+ <XDSText color="secondary">+ Edit the code and see live changes.+ </XDSText>+ </XDSVStack>+ <XDSHStack gap={2} align="center"><XDSButtonlabel={\`Count: \${count}\`}onClick={() => setCount(c => c + 1)}@@ -217,6 +219,13 @@ function configureMonaco(monaco: MonacoInstance) {content,`file:///node_modules/@types/react/${fileName}`,);+ // Also register react/jsx-runtime as a resolvable module path+ if (fileName === 'jsx-runtime.d.ts') {+ ts.addExtraLib(+ content,+ 'file:///node_modules/react/jsx-runtime.d.ts',+ );+ }}const stylexFiles = packages['@stylexjs/stylex'] ?? {};