Description
src/components/app/preview/PreviewIframe.tsx declares customization?: any in PreviewIframeProps (line 8), even though every caller — PreviewWorkspace.tsx passes a CustomizationConfig — already has a properly typed value available. Using any here means JSON.stringify(customization) inside the generatePreviewUrl effect (line 32) and any future consumer of the prop get zero compile-time safety; a caller could pass an unrelated object shape and TypeScript would not catch it, and IDE autocomplete/refactor tooling can't help maintainers working in this file.
Requirements and Context
PreviewIframeProps.customization must be typed as CustomizationConfig | undefined instead of any, matching the type already used by PreviewWorkspaceProps.customization in the same directory.
- No behavior change is expected; this is a type-safety improvement only.
pnpm typecheck must pass with the tightened type, confirming all current call sites already satisfy it.
- Add a type-level or unit test (e.g. a
PreviewIframe.test.tsx render passing a full CustomizationConfig) if no test file currently exists for this component.
Suggested Execution
Branch: refactor/preview-iframe-prop-typing
Implement Changes
- In
src/components/app/preview/PreviewIframe.tsx, import CustomizationConfig from @craft/types and change customization?: any to customization?: CustomizationConfig.
- Re-check the
generatePreviewUrl effect's dependency array and JSON.stringify(customization) call for any implicit any-driven behavior that needs adjusting once the type is narrowed.
- If
src/components/app/preview/PreviewIframe.tsx has no dedicated test file, add a minimal one rendering the component with a typed CustomizationConfig and asserting the generated src URL includes the serialized customization.
- Run
pnpm typecheck to surface and fix any now-visible type errors at call sites.
Test and Commit
Run pnpm typecheck --filter=frontend and pnpm test --filter=frontend -- PreviewIframe to confirm the tightened prop type compiles cleanly and existing preview rendering still works.
Example Commit Message
refactor(frontend): replace any with CustomizationConfig in PreviewIframeProps
Co-authored-by: <your-name>
Guidelines
- Branch off
main, keep PRs focused on one issue
- All new code must include unit or integration tests
- Ensure
pnpm lint and pnpm typecheck pass before review
- Link this issue in your PR description
- Request review from at least one maintainer before merging
Description
src/components/app/preview/PreviewIframe.tsxdeclarescustomization?: anyinPreviewIframeProps(line 8), even though every caller —PreviewWorkspace.tsxpasses aCustomizationConfig— already has a properly typed value available. Usinganyhere meansJSON.stringify(customization)inside thegeneratePreviewUrleffect (line 32) and any future consumer of the prop get zero compile-time safety; a caller could pass an unrelated object shape and TypeScript would not catch it, and IDE autocomplete/refactor tooling can't help maintainers working in this file.Requirements and Context
PreviewIframeProps.customizationmust be typed asCustomizationConfig | undefinedinstead ofany, matching the type already used byPreviewWorkspaceProps.customizationin the same directory.pnpm typecheckmust pass with the tightened type, confirming all current call sites already satisfy it.PreviewIframe.test.tsxrender passing a fullCustomizationConfig) if no test file currently exists for this component.Suggested Execution
Branch:
refactor/preview-iframe-prop-typingImplement Changes
src/components/app/preview/PreviewIframe.tsx, importCustomizationConfigfrom@craft/typesand changecustomization?: anytocustomization?: CustomizationConfig.generatePreviewUrleffect's dependency array andJSON.stringify(customization)call for any implicitany-driven behavior that needs adjusting once the type is narrowed.src/components/app/preview/PreviewIframe.tsxhas no dedicated test file, add a minimal one rendering the component with a typedCustomizationConfigand asserting the generatedsrcURL includes the serialized customization.pnpm typecheckto surface and fix any now-visible type errors at call sites.Test and Commit
Run
pnpm typecheck --filter=frontendandpnpm test --filter=frontend -- PreviewIframeto confirm the tightened prop type compiles cleanly and existing preview rendering still works.Example Commit Message
Guidelines
main, keep PRs focused on one issuepnpm lintandpnpm typecheckpass before review