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

Core: Migrate core to TypeScript #12839

Merged
merged 21 commits into from Nov 4, 2020
Merged

Core: Migrate core to TypeScript #12839

merged 21 commits into from Nov 4, 2020

Conversation

gaetanmaisse
Copy link
Member

@gaetanmaisse gaetanmaisse commented Oct 20, 2020

Issue: Part of #5030 and supersede #9870

What I did

I migrated @storybook/core to TypeScript, some types still need to be refined but the base is here.
A PR had been started in early 2020 about that (#9870) but never gets merged and has too many conflicts now so I just started from scratch here.

I think this is the final step of the TS migration for lib packages 🎉

How to test

  • CI should be 🟢

@gaetanmaisse
Copy link
Member Author

I will push new commits improving typing in the few next days 😉

@gaetanmaisse gaetanmaisse force-pushed the tech/migrate-core-to-TS branch 4 times, most recently from 26ffe19 to 3e7602a Compare October 31, 2020 15:29
@gaetanmaisse
Copy link
Member Author

The types still need some refinement and refactoring but as discussed during the monthly meeting we will merge as it to avoid many conflicts resolution.

I added a big warning to avoid exporting these WIP types and I will work to improve them in the next few days/weeks.

@yannbf was the typing bug you had in mind yesterday the one I fixed in the last commit?

@yannbf
Copy link
Member

yannbf commented Nov 3, 2020

The types still need some refinement and refactoring but as discussed during the monthly meeting we will merge as it to avoid many conflicts resolution.

I added a big warning to avoid exporting these WIP types and I will work to improve them in the next few days/weeks.

@yannbf was the typing bug you had in mind yesterday the one I fixed in the last commit?

Yes, exactly! I was also wondering if options could be Record<string, any> instead of any.. Or do you think options could receive a primitive value rather than an object?

@gaetanmaisse gaetanmaisse marked this pull request as ready for review November 3, 2020 20:44
@gaetanmaisse
Copy link
Member Author

I was also wondering if options could be Record<string, any> instead of any.. Or do you think options could receive a primitive value rather than an object?

I would say no but I'm really not sure so I didn't take the risk 🙈 Let's see what the experts are saying 😄

@gaetanmaisse gaetanmaisse requested review from shilman, yannbf, tooppaaa and mrmckeb and removed request for theinterned and igor-dv November 3, 2020 20:46
}

export interface Presets {
apply(
Copy link
Contributor

Choose a reason for hiding this comment

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

I see the point but isn't too limitative (and potentially incomplete) to list all presets ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I somehow need these types to avoid type inference to "return" any on all these calls: https://github.com/storybookjs/storybook/pull/12839/files#diff-d0f0c842d74746ce0b792a604e01fb7ded59c01898321fb1b482ba3ca016ab7dR12-R28

It's not directly the presets but the functions a preset can expose and so for instance webpack function should/must always return a webpack Configuration whatever the preset. Do you agree? 🤔

But it's not 100% clear for me yet, maybe I will get rid of that when improving the typing.

I'm surely missing some parameters that why I introduced a fallback on L45

import { typeScriptDefaults } from './config/defaults';

/**
* ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now!
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the most important line of code in this file 😁

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.

Great work @gaetanmaisse. 💯

Probably needs refinement, but will merge for now and we can pick that up between now and release, or down the road.

@shilman shilman changed the title Core: migrate sources to TypeScript Core: Migrate core to TypeScript Nov 4, 2020
@shilman shilman merged commit 54b14cf into next Nov 4, 2020
@shilman shilman deleted the tech/migrate-core-to-TS branch November 4, 2020 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants