-
-
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
TypeScript migration organization #5030
Comments
Of course! I hope to get them finished by tomorrow. Just pick whatever addon you want and open a PR 👍 If you want to start right now you also can just migrate the updates into your branch later on |
@kroeder you can update your post to set |
@gaetanmaisse done! |
i can offer to do the @storybook/vue migration once the core package is done |
@ndelangen I just love to do some OSS work now and then 😉 |
Great work @MichaelDeBoey @gaetanmaisse 🙌 🙌 🙌 |
Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.9 containing PR #10802 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
We've just released zero-config typescript support in 6.0-beta. Please upgrade and test it! Thanks for your help and support getting this stable for release! |
Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-beta.2 containing PR #12839 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
🥳 It's over! It's done. 🙇🏻 Thanks to all of you @aromanarguello @emilio-martinez @hcz @lonyele @ndelangen @dandean @sairus2k @wuweiweiwu @MichaelDeBoey! You're all part of this! ❤️ And a special big Thank You to @kroeder for having started and led this at the begginning and help me to make my first contributions to Storybook a few years ago. 🎉 🎆 |
Great Caesar's ghost!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-alpha.14 containing PR #13447 that references this issue. Upgrade today to the
|
What is this?
I want to use this issue for organizing the TypeScript migration process.
What is going to be migrated
I started with
addon-notes
and noticed it depends onchannels
andaddons
so I migrated them as well.I'm not sure if we should migrate every lib but at least those that are used in addons or provide a public api that is used by other apps.
Let's discuss this if someone has other thoughts on this!
General
Apps
Libs
Addons
Deletion of DefinitelyTyped packages
As sources will now be written in TS storybook packages will export their own types definitions so we will be allowed to delete types from DefinitelyTyped (i.e.
@types/storybook-XXX
).Activate TS strict mode
Why use TS strict mode?
noUnusedLocals
put in light the fact that some variables were not used for months but still there and still requiring maintenance.Example on a11y addon: https://github.com/storybookjs/storybook/pull/9180/files
Initial steps for every migration
tsconfig.json
from e.g.addon-notes
into the root of the packagepackage.json
of the package (TODO* We need to figure out how to handle tree shaking)2.1 Remove
jsnext:main
2.2 Add
"types": "dist/%my-entry-point%.d.ts
. If you have multiple files that export things, see: "My package has multiple files with exports"3.1
.js
files to.ts
3.2 files that use
jsx
to.tsx
FAQ
How do I compile TypeScript?
Storybook already compiles TypeScript by using
yarn dev
.I suggest using
yarn dev:ts
because you don't want to compile everything but TypeScript right now.Could not find declaration file for module '...'
This means a package you are importing does not ship declaration files (types) for TypeScript.
This message is caused by
noImplicitAny: true
https://basarat.gitbooks.io/typescript/docs/options/noImplicitAny.htmlExample:
For non-storybook packages
Install additional devDeps from @types, if available:
@types/package-name
If there's no @types package, see "Write your own declaration"
For storybook packages
If a certain package is not in the list above, please add it.
See "Write your own declaration"
Write your own declaration
Add a
typings.d.ts
file to yoursrc
directory.At least declare a module for a package that does not contain declarations.
You can provide additional information. Depends on how important and how often a certain package is used.
See https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
Examples: https://www.typescriptlang.org/docs/handbook/declaration-files/templates.html
My package has multiple files with exports
If your package has exports from multiple files you need to create one file that exports all your public api things.
Example:
public_api.ts
with2.1 Set
My packages has a default export but it can't be imported
This likely means that you use a
public_api.ts
as mentioned above and another file in your package has a default export.In
@storybook/addons
it is solved this wayOne package can have only one default export and it seems to be that it has to be in your
main
file of your package.The text was updated successfully, but these errors were encountered: