-
Notifications
You must be signed in to change notification settings - Fork 4.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
Publish types for plugins package #49649
Conversation
Size Change: +2 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in d78218c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4640724747
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @noahtallen 🙌
I we could aim to get this closer to the existing DT types, at least when it comes to precision. I've left some suggestions, let me know what you think.
Also, let's not forget to add some CHANGELOG entries for a breaking change where applicable (in the plugins package most certainly).
Another fantastic example of a rabbit hole: In order to fix all the type errors and start checking JS, we need to convert the
I did a fair amount of digging yesterday, and couldn't figure out why this one thing causes an issue in this file, but not others. The solution is to keep the types in the docblock, instead of removing them. Definitely not ideal :/ Beyond that, the
|
I also don't think the components change justifies a changelog entry here :p |
I wasn't sure if those errors would just occur locally, but it does look like they spill over here. Would appreciate help figuring them out since they seem completely unrelated :/ |
I haven't had a chance to take a look at these errors myself, but this might indicate that there are existing TS errors in the components package that for some reason are manifesting only when we start explicitly exporting types. cc @ciampo @mirka and @chad1008 in case they have any idea what might be going on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beyond that, the
npm run build:package-types
command will continue outputting errors in unrelated packages like components, and even dependencies like reakit and popper. Who knows why, but when disabling checkJS, it goes away :/
I looked into this, and it's due to an upstream issue in Reakit. It's already been fixed in reakit@1.3.9, so I'll see if I can update our dependency version asap (currently 1.3.8). The quick fix is to add "skipLibCheck": true
in the plugins/tsconfig.json
.
fb2bf89
to
d891337
Compare
Alright, updated the PR:
|
d891337
to
6ea0e84
Compare
07eed21
to
c507730
Compare
* @param {string|undefined} props.scope | ||
* @param {Function|undefined} props.onError | ||
* @param props | ||
* @param props.scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have to list all the properties now that they are statically typed? AFAIR other places just say @param props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My IDE automatically inserts them on save, so I think yes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one more nit but otherwise this is awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great from my perspective 🚀
Left a couple of last-minute CHANGELOG suggestions, good to go after they're addressed.
Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
c507730
to
2b8575c
Compare
Do y'all think that this PR (and the related ones publishing types) deserve a dev note? |
I think that is a great idea. @noahtallen is this something you're planning to work on? I'm happy to collaborate there. |
6.3 Dev Note:Typescript developers appreciate having great in-editor type-hints and compiler warnings. We would also like to reduce our reliance on DefinitelyTyped, as it's much harder to maintain type information separately from the source code. As a result, we are publishing more types for various With some small tweaks to assist its inference capabilities, Typescript can generate extensive type definitions even for store objects without migrating much code to Typescript. So far, we have published types for the following packages using this process:
With work in progress on some larger packages such as |
What?
I'm publishing types for more packages to avoid having to maintain stuff on DT.
Why?
See #49647
How?
Add the tsconfig and fix anything that comes up! Also check final build-types directory.
Testing Instructions
CI