Skip to content

Conversation

@nzws
Copy link
Contributor

@nzws nzws commented Nov 7, 2025

What I did

Removes the unnecessary any return type from the auto-generated getAbsolutePath function in the .storybook/main.ts file of monorepo projects.

This function always return a string. I also checked past PRs related to this code but found no clear reason why the any type was specified. In general, when a project uses linter like ESLint, the any type would trigger an error, so unnecessary any types should not be used.

ref: https://nodejs.org/docs/latest-v20.x/api/path.html#pathdirnamepath
ref: #23458

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

Since I wasn’t sure how to create a monorepo project on the Storybook sandbox, I manually set up the environment.

  1. Create a monorepo project with npx create-turbo@latest
  2. Inside the generated frontend application, run yarn add path/to/create-storybook
  3. Run yarn create-storybook
  4. After completion, check the output of .storybook/main.ts

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 publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Refactor
    • Improved TypeScript type annotations for internal functions to enhance code quality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

📝 Walkthrough

Walkthrough

A single function's explicit return type annotation has been removed from a generated code snippet within the baseGenerator, changing the getAbsolutePath function signature by dropping the : any type indicator.

Changes

Cohort / File(s) Summary
Type annotation removal
code/lib/create-storybook/src/generators/baseGenerator.ts
Removed explicit : any return type annotation from getAbsolutePath function signature in generated main.js template string

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9695ea and 4ee83ef.

📒 Files selected for processing (1)
  • code/lib/create-storybook/src/generators/baseGenerator.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier formatting on changed files before committing
Run ESLint on changed files and fix all errors/warnings before committing (use yarn lint:js:cmd <file>)

Files:

  • code/lib/create-storybook/src/generators/baseGenerator.ts
**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Export functions from modules when they need to be unit-tested

Files:

  • code/lib/create-storybook/src/generators/baseGenerator.ts
code/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

In application code, use Storybook loggers instead of console.* (client code: storybook/internal/client-logger; server code: storybook/internal/node-logger)

Files:

  • code/lib/create-storybook/src/generators/baseGenerator.ts
{code/**,scripts/**}/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/lib/create-storybook/src/generators/baseGenerator.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: normal
🔇 Additional comments (1)
code/lib/create-storybook/src/generators/baseGenerator.ts (1)

418-420: LGTM! Removing the unnecessary any type annotation.

TypeScript will correctly infer the return type as string from the implementation, since dirname() returns a string. This change improves type safety and resolves potential linting errors in generated projects.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@storybook-app-bot
Copy link

Package Benchmarks

Commit: 4ee83ef, ran on 10 November 2025 at 14:36:43 UTC

The following packages have significant changes to their size or dependencies:

@storybook/react-native-web-vite

Before After Difference
Dependency count 156 157 🚨 +1 🚨
Self size 31 KB 31 KB 🚨 +150 B 🚨
Dependency size 23.05 MB 23.11 MB 🚨 +64 KB 🚨
Bundle Size Analyzer Link Link

@github-actions github-actions bot added the Stale label Nov 25, 2025
@valentinpalkovic valentinpalkovic changed the title Remove any return type of getAbsolutePath CLI: Remove any return type of getAbsolutePath Dec 1, 2025
@valentinpalkovic valentinpalkovic merged commit 41c8082 into storybookjs:next Dec 1, 2025
53 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants