Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigFile: Fix as const satisfies modifiers #29000

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

shilman
Copy link
Member

@shilman shilman commented Aug 29, 2024

Closes N/A

What I did

Fix the as const satisfies X case for the ConfigFile helpers

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

In a sandbox, storybook add on a config file that uses export default { } as const satisfies StorybookConfig.

🦋 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>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 76.4 MB 76.5 MB 57 kB 1.88 0.1%
initSize 161 MB 161 MB 56.1 kB -0.53 0%
diffSize 84.8 MB 84.8 MB -828 B -0.54 0%
buildSize 7.48 MB 7.48 MB -26 B 1.36 0%
buildSbAddonsSize 1.62 MB 1.62 MB 0 B 0.33 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.31 MB 2.31 MB -2 B 1.36 0%
buildSbPreviewSize 352 kB 352 kB 0 B 0.33 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.47 MB 4.47 MB -2 B 1.36 0%
buildPreviewSize 3.01 MB 3.01 MB -24 B 1.36 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.7s 23.5s 16.7s 1.31 🔺71.2%
generateTime 19.2s 20.1s 938ms -0.5 4.7%
initTime 16.1s 16.2s 94ms -0.98 0.6%
buildTime 11s 11.1s 92ms -1.06 0.8%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6s 6.5s 481ms -0.86 7.3%
devManagerResponsive 3.9s 4.2s 381ms -0.84 8.9%
devManagerHeaderVisible 1s 795ms -281ms -0.29 -35.3%
devManagerIndexVisible 1.1s 830ms -285ms -0.33 -34.3%
devStoryVisibleUncached 1.3s 1.3s 25ms -0.28 1.8%
devStoryVisible 1.1s 831ms -285ms -0.32 -34.3%
devAutodocsVisible 608ms 790ms 182ms 0.45 23%
devMDXVisible 692ms 747ms 55ms 0 7.4%
buildManagerHeaderVisible 656ms 753ms 97ms -0.11 12.9%
buildManagerIndexVisible 662ms 785ms 123ms 0.1 15.7%
buildStoryVisible 692ms 787ms 95ms -0.4 12.1%
buildAutodocsVisible 668ms 604ms -64ms -1.48 🔰-10.6%
buildMDXVisible 586ms 661ms 75ms -0.42 11.3%

Greptile Summary

This PR enhances the ConfigFile class to handle TypeScript's 'as const satisfies' syntax in Storybook configuration files.

  • Added 'unwrap' function in ConfigFile.ts to handle 'as const' and 'satisfies' expressions
  • Updated existing methods to use 'unwrap' for proper AST node processing
  • Added new test case in ConfigFile.test.ts for 'as const satisfies' scenario
  • Improves compatibility with TypeScript-specific syntax in Storybook configs

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.

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Comment on lines +804 to +808
const preview = {
globals: { a: 1 },
bar: { a: 1 }
} as const satisfies Foo;
export default preview;
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: Typo in test name: 'satsifies' should be 'satisfies'

Copy link

nx-cloud bot commented Aug 29, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit bd3373e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@@ -795,6 +795,26 @@ describe('ConfigFile', () => {
export default preview;
`);
});

it('root globals as const satsifies as variable', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

@shilman shilman merged commit 77c37c8 into next Aug 29, 2024
3 of 4 checks passed
@shilman shilman deleted the shilan/fix-configfile-as-const-satisfies branch August 29, 2024 12:21
@github-actions github-actions bot mentioned this pull request Aug 29, 2024
9 tasks
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