-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Bug]: @storybook/csf-tools doesn't parse .storybook/main.ts config properly if using satisfies StorybookConfig
#20935
Comments
You need to migrate the https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#esm-format-in-mainjs Lines 325 to 335 in 293d52c
|
@zhyd1997 Yeah that is the only way currently, but I think it makes sense that satisfies is also supported. I wouldn't necessarily call the current suggestion the correct way. For these config type files, using satisfies provides a much more accurate resultant type than typing the entire thing as |
Hi @stevezhu const config = {
// ...
}
export default config satisfies StorybookConfig this way also works. |
@zhyd1997 Thanks for the suggestions I'm aware of how to fix it, this issue is more of a feature request for satisfies support for configs. I would prefer to be able to export it directly without the intermediate declaration. Also for context on this thread, there's satisfies support for csf meta #20033 so it would be consistent to also support it for configs. |
Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.44 containing PR #20936 that references this issue. Upgrade today to the
|
Describe the bug
Issue
If using typescript storybook config and
satisfies
from typescript 4.9 to typecheckinstead of something like
the ast isn't handled properly.
As you can see below in the asts under "Additional context", when using the
satisfies
operator, theObjectExpression
is wrapped in any extraTSSatisfiesExpression
node which causes the code to break.A new unit test is probably needed in https://github.com/storybookjs/storybook/blob/next/code/lib/csf-tools/src/ConfigFile.test.ts that tests the
satisfies
operator.My storybook config for example:
.storybook/main.ts
Root Cause
This began in version
v7.0.0-beta.39
.The following call seems to spam the warning log from the following line starting in
v7.0.0-beta.39
.https://github.com/storybookjs/storybook/blob/v7.0.0-beta.39/code/lib/csf-tools/src/ConfigFile.ts#L155
This is probably because of a newly added call to
readConfig
here that ends up hitting the previous piece of code, which didn't exist inv7.0.0-beta.38
.https://github.com/storybookjs/storybook/blob/v7.0.0-beta.39/code/lib/core-common/src/utils/validate-configuration-files.ts#L28
Temporary workaround (if using pnpm)
Add to package.json
To Reproduce
Can probably reproduce just by adding a new test to https://github.com/storybookjs/storybook/blob/next/code/lib/csf-tools/src/ConfigFile.test.ts that uses the satisfies operator`.
System
Additional context
Unsupported AST (with
satisfies
)Supported AST (without
satisfies
)The text was updated successfully, but these errors were encountered: