Skip to content

Conversation

@jonniebigodes
Copy link
Contributor

@jonniebigodes jonniebigodes commented Aug 10, 2025

Follows up on #31930

What I did

With this pull request, the examples referencing preview files were updated to provide the correct type imports to align with the rest of the documentation.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

This PR fixes TypeScript import syntax in Storybook documentation snippets by standardizing the use of explicit type imports. The changes update import { Preview } from '@storybook/your-framework' to import type { Preview } from '@storybook/your-framework' across 8 documentation files in the docs/_snippets/ directory.

The affected files include preview configuration examples for various Storybook features and addons:

  • a11y addon configuration and parameter examples
  • viewport addon configuration and custom viewport examples
  • code panel enabling
  • before-all and before-each testing setup examples

This change aligns with TypeScript best practices for type-only imports, which provide several benefits: they make the intent explicit that imports are used solely for type annotations, allow TypeScript to optimize builds by stripping these imports during compilation, and improve semantic clarity by distinguishing between runtime dependencies and compile-time types.

The modification is part of a broader effort to ensure consistency across all Storybook documentation examples and follows up on issue #31930. Since the Preview interface is only used for type annotation (const preview: Preview = { ... }), it should be imported as a type rather than a value. This change maintains full functional equivalence while demonstrating the recommended TypeScript patterns to users copying these examples.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only affects documentation snippets
  • Score reflects simple, consistent changes that follow TypeScript best practices without any functional modifications
  • No files require special attention as all changes are identical type import syntax updates

@jonniebigodes jonniebigodes self-assigned this Aug 10, 2025
@jonniebigodes jonniebigodes added documentation patch:yes Bugfix & documentation PR that need to be picked to main branch ci:docs Run the CI jobs for documentation checks only. labels Aug 10, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@nx-cloud
Copy link

nx-cloud bot commented Aug 10, 2025

View your CI Pipeline Execution ↗ for commit 568fc7e

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 18s View ↗

☁️ Nx Cloud last updated this comment at 2025-08-11 18:04:34 UTC

Copy link
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jonniebigodes jonniebigodes merged commit 7e7e513 into next Aug 11, 2025
8 checks passed
@jonniebigodes jonniebigodes deleted the docs_fix_type_imports_snippets branch August 11, 2025 18:04
@ndelangen ndelangen changed the title Docs: Fix preview examples imports Addons: Fix preview examples import examples Aug 20, 2025
@ndelangen ndelangen changed the title Addons: Fix preview examples import examples Addons: Fix preview import examples Aug 20, 2025
ndelangen pushed a commit that referenced this pull request Aug 20, 2025
…pets

Docs: Fix preview examples imports
(cherry picked from commit 7e7e513)
ndelangen pushed a commit that referenced this pull request Aug 21, 2025
…pets

Docs: Fix preview examples imports
(cherry picked from commit 7e7e513)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Aug 21, 2025
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:docs Run the CI jobs for documentation checks only. documentation patch:done Patch/release PRs already cherry-picked to main/release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants