-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Convert wp data controls to typescript #49647
Conversation
deprecated( '`select` control in `@wordpress/data-controls`', { | ||
since: '5.7', | ||
alternative: 'built-in `resolveSelect` control in `@wordpress/data`', | ||
} ); | ||
|
||
return dataControls.resolveSelect( ...args ); |
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.
Typescript wasn't happy about this because it's not specific enough.
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 like it, it's way more predictable that way.
@@ -24,7 +26,7 @@ import deprecated from '@wordpress/deprecated'; | |||
* | |||
* @return {Object} The control descriptor. | |||
*/ | |||
export function apiFetch( request ) { | |||
export function apiFetch( request: APIFetchOptions ) { |
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.
APIFetchOptions is what DT uses for this
Size Change: +32 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in af509a6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4640716824
|
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.
Nice 👍 Looks good from my perspective.
I'd say this could use a CHANGELOG entry, though. I'd say it's a breaking change since anyone who uses the DT package will get duplicate module declaration errors.
deprecated( '`select` control in `@wordpress/data-controls`', { | ||
since: '5.7', | ||
alternative: 'built-in `resolveSelect` control in `@wordpress/data`', | ||
} ); | ||
|
||
return dataControls.resolveSelect( ...args ); |
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 like it, it's way more predictable that way.
Done! |
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.
Looks great from my perspective 🚀
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.
Approving preemptively. I would like to see a merge of one of these several PRs first (either this one or notices, which are simpler than the third) so we can see if we unintentionally cause problems for those relying already on DefinitelyTyped.
Ultimately I don't think that's a hard constraint, but I'm a bit nervous as we get started with this process. What do you think?
I'm in the same camp, for what it's worth. We've been discussing that with Noah and I think going with those simpler packages is a good way to navigate the uncharted lands. |
What do we think the best path forward is? Essentially, what will happen is this gets published as a new major version, and then we'll remove it from DT. That will ultimately publish a new version of the DT package that's just a stub. However, we won't really see anything from consumers until this is actually published as a new major version, in the typical 2-week release cycle. At that point, though, we should be able to issue patch fixes to resolve issues that come up. Given that these will all be major versions, we won't be automatically causing issues for people. However, I'm not a huge fan of delaying the project to the biweekly releases. (For example, if we only release a single package, we'll then have to wait two weeks to release other packages with breaking changes.) FWIW, this is easily the simplest package to publish since it's a single file which is fully type checked :D |
I'll merge this first and hold off on the others for now. (Plus they have some more work I think) |
Removing from DT now that this was published :) DefinitelyTyped/DefinitelyTyped#65111 |
So I think this has accidentally happened anyways. This change just got published, but we didn't finish the others yet. So now we get a chance to see how it went! |
What?
Converts data-controls to Typescript.
Why?
The main motivation is that it's frustrating trying to maintain DefinitelyTyped at the same time, when we only need minimal changes to include types here :)
I ended up converting the file to typescript, mostly just because the package is a single file, so it was very easy to do that.
Is anything else needed to finish this?
How?
Convert to typescript and clarify any types as needed.
Testing Instructions
Testing Instructions for Keyboard
code-only change
Screenshots or screencast