-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
CLI: add type annotations in javascript main config files #20887
Conversation
Open question: Given that in Typescript we generate this: import { StorybookConfig from } '@storybook/react-vite'
const config: StorybookConfig {
"stories": [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
};
export default config We could potentially make js look like this and keep the files more consistent: /** @type { import('@storybook/react-vite').StorybookConfig } */
const config = {
"stories": [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
};
export default config and probably in the docs we follow a similar pattern than for Typescript: // Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-webpack5)
/** @type { import('@storybook/your-framework).StorybookConfig } */
const config = {
"stories": [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
};
export default config WDYT @kasperpeulen @jonniebigodes @shilman ? |
@yannbf That's really cool!! ❤️ To clarify: you're not saying get rid of the generated TS in CLI or documentation, but simply how to improve the JS side of things, right? |
Yup, for sure! |
This is amazing @yannbf 🤩 ! If I understand this correctly, I think we can probably shrink down the number of code snippet files we have in our documentation. I'll follow up with you on it, and we'll go from there. Thank you both for thinking about this (@yannbf and @JReinhold ). Appreciate it 🙏 |
I think this is great! @jonniebigodes I don't think it would not reduce the code snippets, but make them more consistent right @yannbf ? On the other hand, we should really just generate the JS examples from the TS examples with a codemod! @shilman What do you think, should be achievable right? |
Interesting idea @kasperpeulen -- I like it as a post 7.0 task |
081aa68
to
7a994fa
Compare
Issue: N/A
What I did
I realized we could get type annotations in javascript for main.js too (thanks @JReinhold)
so this PR changes the generated main.js files to:
It also adds tests to the file, which had none so far
How to test
Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]