Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/blob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _Parameters_

_Returns_

- `?File`: The file for the blob URL.
- `(File|undefined)`: The file for the blob URL.

<a name="isBlobURL" href="#isBlobURL">#</a> **isBlobURL**

Expand Down
5 changes: 4 additions & 1 deletion packages/blob/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*/
const { createObjectURL, revokeObjectURL } = window.URL;

/**
* @type {{[key: string]: File|undefined}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

*/
const cache = {};

/**
Expand All @@ -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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{?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".

*/
export function getBlobByURL( url ) {
return cache[ url ];
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */

/* Additional Checks */
Expand All @@ -21,6 +22,7 @@
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
},
"include": [
"./packages/blob/**/*.js",
"./packages/dom-ready/**/*.js",
"./packages/i18n/**/*.js",
"./packages/is-shallow-equal/**/*.js",
Expand Down