-
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
Convert blob package to TS #62569
Convert blob package to TS #62569
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Added |
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.
Thanks for picking up this work. All the types need to be removed from JSDoc because they're moving into TypeScript annotations.
packages/blob/src/index.ts
Outdated
type BlobPart = BufferSource | Blob | string; | ||
|
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.
We shouldn't need this, it's part of the DOM types.
type BlobPart = BufferSource | Blob | string; |
packages/blob/src/index.ts
Outdated
@@ -94,7 +93,11 @@ export function isBlobURL( url ) { | |||
* @param {BlobPart} content File content (BufferSource | Blob | string). |
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.
Eslint complained here about the param type, but this has been converted to TypeScript so we need to remove all the types from JSDoc.
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.
@sirreal please review now I have removed the param type.
Use ts-expect-error over ts-ignore Use toBeUndefined over toBe( undefined )
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.
Thanks!
packages/blob/src/test/index.ts
Outdated
@@ -13,6 +13,8 @@ describe( 'isBlobURL', () => { | |||
} ); | |||
|
|||
it( 'returns false if the url is not defined', () => { | |||
// calling isBlobURL without a URL is not type compliant, so ignore it | |||
// @ts-ignore |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
packages/blob/src/test/index.ts
Outdated
// calling getBlobTypeByURL without a URL is not type compliant, so ignore it | ||
// @ts-ignore | ||
expect( getBlobTypeByURL() ).toBe( undefined ); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
packages/blob/src/test/index.ts
Outdated
window.URL.createObjectURL = createObjectURL; | ||
window.URL.revokeObjectURL = revokeObjectURL; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
I will note these points for the next TS conversion PRs. |
Co-authored-by: jpstevens <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: sirreal <[email protected]> Co-authored-by: up1512001 <[email protected]>
What?
This PR converts the
blob
package to TypeScript.Why?
Ensures package is fully type checked.
How?
Testing Instructions
npm run test:unit -- packages/blob
tests passnpm run build:package-types
returns a zero exit codereference PR
Closes #61541