Skip to content
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

Blob: Add types #19092

Merged
merged 2 commits into from Dec 12, 2019
Merged

Blob: Add types #19092

merged 2 commits into from Dec 12, 2019

Conversation

@sirreal
Copy link
Member

sirreal commented Dec 12, 2019

Description

Part of #18838
Extracted from #18942

Add types to blob package.

Testing Instructions:

Verify type checking passes:

npm run lint-types
@@ -3,6 +3,9 @@
*/
const { createObjectURL, revokeObjectURL } = window.URL;

/**
* @type {{[key: string]: File|undefined}}

This comment has been minimized.

Copy link
@sirreal

sirreal Dec 12, 2019

Author Member

Initially, my editor ignored the | undefined part of this type and the following one. Adding explicit strictNullChecks to the tsconfig restored it.

@@ -27,7 +30,7 @@ export function createBlobURL( file ) {
*
* @param {string} url The blob URL.
*
* @return {?File} The file for the blob URL.
* @return {File|undefined} The file for the blob URL.

This comment has been minimized.

Copy link
@sirreal

sirreal Dec 12, 2019

Author Member

{?File} is a nullable type in JSDoc, equivalent to File | null, which isn't accurate.

This comment has been minimized.

Copy link
@aduth

aduth Dec 12, 2019

Member

{?File} is a nullable type in JSDoc, equivalent to File | null, which isn't accurate.

Yeah, I think you'll find a lot of examples like this in the codebase, where nullable type is used incorrectly as interchangeable with "optional" or "possibly undefined".

@@ -12,6 +12,7 @@

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"strictNullChecks": true,

This comment has been minimized.

Copy link
@sirreal

sirreal Dec 12, 2019

Author Member

This should be enabled via strict, but I some Type | undefined types didn't seem to be handled correctly. Adding this seems to fix the issue.

I wonder if strict + noImplicitAny results in odd behavior.

@sirreal sirreal marked this pull request as ready for review Dec 12, 2019
@sirreal sirreal requested a review from aduth as a code owner Dec 12, 2019
@aduth aduth mentioned this pull request Dec 12, 2019
9 of 67 tasks complete
@aduth
aduth approved these changes Dec 12, 2019
@sirreal sirreal force-pushed the add/types-blob branch from fefa371 to 9d8ae89 Dec 12, 2019
@sirreal sirreal merged commit 96ab640 into master Dec 12, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@sirreal sirreal deleted the add/types-blob branch Dec 12, 2019
@youknowriad youknowriad added this to the Gutenberg 7.2 milestone Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.