Repository navigation
internal(website): Declare playground editor globals with valid TypeScript - #4136
Conversation
Split the 362-line monaco-init into focused modules (setup, typeLibs, theme, navigation, modelPath), group preview execution under preview/, and replace forwarding modules with direct imports. Behavior is unchanged; the new README documents the SSR, incremental-loading, mobile/bot and hidden-tab invariants a future change must keep. - monaco/: setup side effect, table-driven type libs (same chunks and order), cross-tab navigation, `/<id>/<path>` model URI helpers - editor/: InteractiveEditor (Monaco or mobile react-live) and StaticEditor (SSR/crawler/loading markup) - userAgent.ts: one source for bot/mobile regexes (isGoogleBot → isBot) - Remove PlaygroundEditor, PlaygroundLiveEditor, DiffEditorChooser aliases, the unused readOnly prop, and unreferenced resources/ - Unit tests for highlight selections and model paths Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
CI runs Playground unit tests without website dependencies installed, so parse the highlight range in InteractiveEditor and pass line numbers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
…ffEditorChooser, readOnly and resources Keep these entry points and the readOnly option available for future use; they now point at the reorganized editor modules. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
cf2de88 brought the dead files and the unused editor prop back. This commit restores the deletions Staff already accepted. Review: #4104 (review) Co-authored-by: Nathaniel Tucker <me@ntucker.me>
Reverts 82bf2d0 per Nathaniel's choice to keep PlaygroundEditor, DiffEditorChooser, the readOnly prop and Playground/resources for now. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
…hain Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
…re path= metastrings Import completions for relative paths now list only files from the same playground instead of every Monaco model on the page. Fence metastrings accept unquoted path=a.ts (used in docs/rest/api/RestEndpoint.md). Also prettier-formats the Playground README. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
…cript
`declare globals { … }` is not TypeScript; the playground globals only typed
because parser error recovery leaked the wrapped declarations into global
scope, and DateTimeFormat silently became `any`.
Mount editor-types/globals.d.ts as a module and alias its exports, React,
JSX, NumberFlow, Temporal, DateTimeFormat and Manager into `declare global`.
Also type TextInput/TextArea/Formatted props that referenced unresolved names.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TkVym3YjjuSjBKhLLwvZm6
…to claude/project-thread-ynhl0c
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TkVym3YjjuSjBKhLLwvZm6
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4136 +/- ##
=======================================
Coverage 98.06% 98.06%
=======================================
Files 163 163
Lines 3095 3095
Branches 616 616
=======================================
Hits 3035 3035
Misses 18 18
Partials 42 42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…er.js in playgrounds (#4137) Mount real declarations for `react/jsx-runtime` (was an empty stub), `path-to-regexp` (never mounted, so @data-client/rest's PathFunction and ParamData were unresolved) and `bignumber.js` (stub whose types were never mounted), and declare `BigNumber` as a playground global since the preview scope provides it. Claude-Session: https://claude.ai/code/session_01W5R8xxJwz7dAy3Uk2v5eH5 Co-authored-by: Claude <noreply@anthropic.com>
* internal(website): Type React jsx-runtime, path-to-regexp and bignumber.js in playgrounds Mount real declarations for `react/jsx-runtime` (was an empty stub), `path-to-regexp` (never mounted, so @data-client/rest's PathFunction and ParamData were unresolved) and `bignumber.js` (stub whose types were never mounted), and declare `BigNumber` as a playground global since the preview scope provides it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W5R8xxJwz7dAy3Uk2v5eH5 * internal(website): Type csstype and number-flow in playgrounds React's CSSProperties and NumberFlow's props resolved through unmounted modules, so style values and NumberFlow format/trend/plugins were any. Mount csstype (comments stripped, 85KB -> 31KB gzipped) and a bundled number-flow/lite; number-flow/plugins re-exports from it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SP4rqYKdew65uNyP8xeJ9m * internal(website): Bundle @number-flow/react types with number-flow Bundle @number-flow/react's .d.ts with its number-flow/lite and number-flow/plugins imports inlined, instead of mounting those as separate modules with a hand-written plugins stub. uuid and number-flow now share one editor-types rollup config and resolver. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SP4rqYKdew65uNyP8xeJ9m --------- Co-authored-by: Claude <noreply@anthropic.com>
…e-lib helpers - One metaValue() parser for title= and path= (quotes optional for both) - One anchored model-id regex; stripModelId is a replace - Mark preview-scope global libs in MODULE_LIBS instead of modules[0] - language is required on InteractiveEditor (codeModel always sets it) - Drop unused return from Monaco setup Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015H36Yk4WBpytw9L7RRVCTK
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TkVym3YjjuSjBKhLLwvZm6
…to claude/project-thread-ynhl0c # Conflicts: # website/src/components/Playground/monaco/typeLibs.ts
#4104 landed on master; keep this branch's typeLibs.ts and README.md. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TkVym3YjjuSjBKhLLwvZm6
Bundle globals.d.ts from the editor-types rollup config (one rollup run, identical output), make mockFetch generic to match its editor declaration, and trim the README note. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TkVym3YjjuSjBKhLLwvZm6
Requested by Nathaniel · project thread
Follow-up from the Staff review on #4104.
Motivation
Before:
typeLibs.tsregistered four libs asdeclare globals { … }, which is not TypeScript. Playground globals still typed only because TS parser error recovery turns that into an expression plus a block in a script file, leaking everything inside to global scope.DateTimeFormat(not an export of the temporal lib) silently becameany,useandmockFetch(both in the preview scope) were "Cannot find name", andTextInput/TextArea/Formattedprops referenced unresolved names (InputHTMLAttributes,Formatter), so they wereany.After: every extra lib is valid TS with zero lib diagnostics. The same globals type-check, and the missing ones are now typed:
Solution
editor-types/globals.d.tsis mounted as an ambient module (playground-globals), withtypedropped from its export list. Then one module-file lib aliases each export intodeclare globalwithexport import X = _globals.X, alongsideReact,JSX(=React.JSX),use,NumberFlow,Temporal,DateTimeFormat,BigNumberandManager.Array/Objectstay built-in (they would redeclare lib globals;schema.Arrayworks).<strike>JSX augmentation now targetsdeclare module 'react'.mockFetch, andTextInput/TextArea/FormatteduseReact.*types.TextAreausesTextareaHTMLAttributes(in the component too), sinceInputHTMLAttributeslacksrowsand would have flaggeddocs/core/shared/_useLoading.mdx.react/jsx-runtime,path-to-regexp,bignumber.js), merged into this branch.Verification
JSX.Elementand<strike>resolve as before,DateTimeFormat/useare now typed, and unknown names still error.addTypeLibsover all 143 playgrounds (348 files acrossdocs/incl. Vue, blog and homepage demos): 0 files with changed diagnostics.yarn workspace rdc-website typecheck,yarn lintand Playground tests clean.Notes
Names only typed before through the leak (e.g.
Controller,State, internal$1helpers) are no longer global. No docs playground uses them without importing. A globalIntlis not redeclared since it would clash with the lib'sIntl.🤖 Generated with Claude Code
https://claude.ai/code/session_01TkVym3YjjuSjBKhLLwvZm6
Note
Low Risk
Changes are limited to docs playground Monaco typings and editor-types build scripts; runtime preview behavior is unchanged aside from stricter TypeScript on design-system props.
Overview
Replaces invalid
declare globals { … }Monaco extra libs with proper module mounting and aglobalScopeLib()that aliases preview-scope exports (from rollupglobals.d.tsviaplayground-globals) intodeclare globalusingexport import, alongsideReact,use,NumberFlow,Temporal,DateTimeFormat, andBigNumber.Array/Objectare skipped so built-in types stay intact.Editor-types pipeline:
copywebsitetypes.shnow stripscsstypecomments, fixesreact/jsx-runtimeimports, copiespath-to-regexpand updatedbignumber.jstypings, and runs a singleeditor-types.rollup.config.js(replacing separate uuid/globals rollups) to bundle uuid, inlined@number-flow/react, and globals.typeLibs.tsaddscsstype,react/jsx-runtime, andpath-to-regexpmodule libs; moves the<strike>JSX augmentation todeclare module 'react'; and extends preview-scope declarations (mockFetch,React.*prop types).TextAreaandmockFetchinscope.tsget matching type fixes (TextareaHTMLAttributes, generics).Reviewed by Cursor Bugbot for commit 67c0524. Bugbot is set up for automated code reviews on this repo. Configure here.