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

TypeScript: Re-structure types for frameworks and presets #18504

Merged
merged 49 commits into from
Jun 29, 2022

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jun 17, 2022

What I did

after discussion on #18432

  • I ensured types flow from:
    core-commoncore-webpackpreset-react-webpackreact-webpack5
    And did this for all presets and frameworks.
    At each level customizations are made to make types more strict
  • Added a framework.options.builder field, which is equal to core.builder.options
    This way users of a framework don't have to specify a builder if they want to configure something in the framework

DEMO:

Screen.Recording.2022-06-17.at.16.39.21.mov

I also changed all the main.JS files of all examples into a main.TS file and ensured it uses the type from the framework is for.

I removed the 6-0 and 7-0 types in renderers.

I changed all stories and example code to deal with the change in 7.0 where what used to be Story is now StoryFn

I reorganized the renderers and frameworks to be simpler, and more in sync with each other. (there's still some work to do here actually.
To be precise, it seems the types for react are way, WAY better.

…ch other

Also map framework.options.builder into core.builder.options
@nx-cloud
Copy link

nx-cloud bot commented Jun 17, 2022

☁️ Nx Cloud Report

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

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@ndelangen ndelangen changed the base branch from next to future/base June 17, 2022 14:33
@ndelangen ndelangen self-assigned this Jun 17, 2022
@ndelangen
Copy link
Member Author

I'm thinking we should rename /types to something else.

Maybe /config?

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Can you update examples to show how this is used?

frameworks/react-webpack5/src/types.ts Show resolved Hide resolved
frameworks/react-webpack5/src/types.ts Show resolved Hide resolved
frameworks/react-webpack5/src/preset.ts Show resolved Hide resolved
@ndelangen
Copy link
Member Author

ndelangen commented Jun 20, 2022

@tmeasday I did update the examples' main.ts if needed, but most of them didn't change all that much:

import type { StorybookConfig } from '@storybook/react-webpack5/types';
const config: StorybookConfig = {

import type { StorybookConfig } from '@storybook/react-webpack5/types';
const config: StorybookConfig = {

import type { StorybookConfig } from '@storybook/react-webpack5/types';
const path = require('path');
const mainConfig: StorybookConfig = {

@tmeasday I'm working on a PR where I migrate all examples to use main.ts to ensure all these types from frameworks work.

frameworks/ember/src/types.ts Outdated Show resolved Hide resolved
@ndelangen ndelangen requested a review from shilman June 20, 2022 14:17
@ndelangen
Copy link
Member Author

@shilman please re-review?

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Generally looks great. A couple of nitpicks. Sorry for the slow review!

presets/svelte-webpack/src/types.ts Outdated Show resolved Hide resolved
export type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> =
StorybookConfigBase<TWebpackConfiguration>;

export type SvelteOptions = {
Copy link
Member

Choose a reason for hiding this comment

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

How does this get associated with any of the config types? Or is that not necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

It gets composed here:

export type FrameworkOptions = SvelteOptions & {
builder?: BuilderOptions;
};

presets/vue3-webpack/src/types.ts Outdated Show resolved Hide resolved
# Conflicts:
#	docs/snippets/html/button-story-with-args.ts.mdx
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Looking good! Merging this

@shilman shilman changed the title future - re-structure our types of frameworks and presets. TypeScript: Re-structure types for frameworks and presets Jun 29, 2022
@shilman shilman merged commit e3308f6 into future/base Jun 29, 2022
@shilman shilman deleted the future/SB-444 branch June 29, 2022 10:31
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.

3 participants