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 |
ciampo
left a comment
There was a problem hiding this comment.
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)
sirreal
left a comment
There was a problem hiding this comment.
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
DateTimePickerto TypeScript.Why?
Continues from #40775 which converted
DateTimePickeritself to TypeScript.How?
Everything was straightforward except for the call to
expect( console ).toHaveWarned().This matcher is added by the
@wordpress/jest-consolepackage. We do not currently have any type declarations for these matchers.It's difficult to convert
@wordpress/jest-consoleto TypeScript or to add JSDoc type annotations to@wordpress/jest-consolebecause it relies onjest.extend()which modifies thejestglobal.So instead I opted to manually write a
.d.tsfile 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