-
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
Add jest-console typings and convert DateTimePicker tests to TypeScript #40957
Conversation
Size Change: +403 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
@sarayourfriend and @sirreal , do you have any thoughts on what would be the best way to add types to |
I did a little more Googling and experimenting and am convinced that So what I'm unsure about is where that
|
I recently added some types and I ended up putting them in the Edit: I've only seen your comment now referencing the |
Maybe we could borrow that nomenclature though and use |
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.
Code changes LGTM 🚀
Let's see what other folks say re. the jest-console
typings — once we're good on those, we can merge.
(also, I may not be able to give this PR another round of reviews as I'll be AFK from tomorrow for a week-ish)
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.
This seems like a good way to type jest-console. It will benefit Gutenberg and external consumers.
OK, all done. I'll have to wait until the package is released before I can open a PR in DefinitelyTyped to remove |
What?
Converts the unit tests for
DateTimePicker
to TypeScript.Why?
Continues from #40775 which converted
DateTimePicker
itself to TypeScript.How?
Everything was straightforward except for the call to
expect( console ).toHaveWarned()
.This matcher is added by the
@wordpress/jest-console
package. We do not currently have any type declarations for these matchers.It's difficult to convert
@wordpress/jest-console
to TypeScript or to add JSDoc type annotations to@wordpress/jest-console
because it relies onjest.extend()
which modifies thejest
global.So instead I opted to manually write a
.d.ts
file for@wordpress/jest-console
. Not sure that this is the best approach, though. One concern is that the type declarations can drift away from what's actually insrc
.Testing Instructions
npm run test