Skip to content

Conversation

@brettearle
Copy link
Contributor

@brettearle brettearle commented May 11, 2025

Closes #31450

What I did

aligned sveltekit js and ts template to not throw errors upon add to sveltekit js project

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!

No manual test necessary

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

Updates the SvelteKit JavaScript template to align with TypeScript template behavior and fix type errors during SvelteKit's built-in type checking.

  • Modified user state initialization from $state(null) to $state() in code/frameworks/sveltekit/template/cli/js/Page.svelte
  • Updated logout handler to use undefined instead of null for better type safety
  • Ensures consistent behavior between JavaScript and TypeScript templates

Summary by CodeRabbit

  • Bug Fixes
    • Improved user state initialization and reset behavior during logout for more reliable session management.

✏️ Tip: You can customize this high-level summary in your review settings.

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.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

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.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@brettearle brettearle changed the title fix: js template aligns with ts template fix: js template aligns with ts template in sveltkit framework May 11, 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.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

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.

LGTM

1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile

@storybook-app-bot
Copy link

storybook-app-bot bot commented Jul 10, 2025

Package Benchmarks

Commit: 2007c78, ran on 9 December 2025 at 07:58:34 UTC

No significant changes detected, all good. 👏

@brettearle
Copy link
Contributor Author

G'day, wondering what needs to happen here to get this over the line?

@JReinhold JReinhold self-requested a review December 8, 2025 22:59
Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

Sorry, this fell through the cracks of my notifications. 🙇

@nx-cloud
Copy link

nx-cloud bot commented Dec 9, 2025

View your CI Pipeline Execution ↗ for commit 2007c78


☁️ Nx Cloud last updated this comment at 2025-12-09 07:50:12 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

📝 Walkthrough

Walkthrough

Modified the user state initialization and logout reset behavior in a Svelte component. Changed the initial state from explicit $state(null) to $state(), and updated the logout handler to reset the user value from null to undefined.

Changes

Cohort / File(s) Summary
Svelte component state initialization
code/frameworks/sveltekit/template/cli/js/Page.svelte
Modified user state initialization from explicit $state(null) to $state() and updated logout handler to reset user to undefined instead of null

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes


📜 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 91d158e and 2007c78.

📒 Files selected for processing (1)
  • code/frameworks/sveltekit/template/cli/js/Page.svelte (1 hunks)
⏰ 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). (2)
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: normal
🔇 Additional comments (1)
code/frameworks/sveltekit/template/cli/js/Page.svelte (1)

5-5: JS template user state now matches intended User | undefined shape

Switching from let user = $state(null) to let user = $state() and resetting to undefined on logout cleanly matches the user pattern described in the linked issue (no null, just { name: string } | undefined). This should remove the null-related type errors from svelte-check while keeping runtime behavior consistent for typical truthiness checks in the template and Header.svelte.


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.

@brettearle
Copy link
Contributor Author

All good , thankyou @JReinhold, I disappeared for a tad also. Let me know if anything needs doing here.

@JReinhold JReinhold changed the title fix: js template aligns with ts template in sveltkit framework SvelteKit: Align JS template with TS template Dec 9, 2025
@JReinhold JReinhold added the bug label Dec 9, 2025
@JReinhold JReinhold merged commit 06dcd57 into storybookjs:next Dec 9, 2025
58 of 62 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.

[Bug]: Sveltekit JS template causes issues with built in svelte scripts in sveltekit projects

4 participants