-
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
api-fetch: Type the rest of the package #30161
Conversation
Size Change: +370 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
09e6e5f
to
8292d0d
Compare
} ); | ||
return ( | ||
window | ||
// @ts-ignore |
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.
Were we going to type this one, too?
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.
No, I wasn't sure where these came from or how to type them effectively without having to declare the types for all the things that TS is doing a good job of inferring. How does the nonceMiddleware
end up on apiFetch
?
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 see. Well, this is a mess 😉 Should it have been a part of the nonce middleware instead? It's definitely something we can fix in another PR anyway.
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.
Just saw this. nonceMiddleware
and nonceEndpoint
are being used in Core:
It definitely can use some improvements though 😅 .
@@ -5,17 +5,13 @@ | |||
"declarationDir": "build-types" | |||
}, | |||
"references": [ | |||
{ "path": "../i18n" }, |
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.
👍
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've left some nitty suggestions and comments, but I believe this looks great already ❤️
} ); | ||
return ( | ||
window | ||
// @ts-ignore |
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 see. Well, this is a mess 😉 Should it have been a part of the nonce middleware instead? It's definitely something we can fix in another PR anyway.
* api-fetch: Type the rest of the package * Update CHANGELOG * Undo spread operator * Fall back to window.location * Use location.href instead of toString and fix comments
I cherry-picked this PR to the Gutenberg plugin 10.3 release. |
Description
This depends on #30150. It types the rest of
api-fetch
.Unfortunately because
fetch-all-middleware
depends onindex.js
it's not possible to do them separately. Luckily there are very few runtime changes in this PR (only two really).How has this been tested?
Type checks and unit tests pass
Types of changes
New feature! Publicly exposed type definitions for the package 🎉
Checklist: