-
Notifications
You must be signed in to change notification settings - Fork 3.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
Fix closure warnings in JS library code #21670
base: main
Are you sure you want to change the base?
Conversation
935bbdf
to
ca0367c
Compare
For some reason closure doesn't report these real issues in the current configuration but they show up in the `MODULARIZE_INSTANCE` configuration that I'm working on. Most of these issues consist of adding default parameters to functions declared on objects such as `FS`. In addition there are a couple of other changes that are all real fixes: - ErrnoError unified between old FS and wasm FS. This should have been done as part of emscripten-core#21149 - Default initializer for `canvasResizedCallbackTargetThread` removed since `JSEvents.getTargetThreadForEventCallback()` will always return undefined when called with no arguments - Extra arguments to copyIndexedColorData removed in library_sdl.js since it only ever called with one arg. - Sorting callback for JSEvents.deferredCalls.sort updated to correctly return number rather than a boolean. This change is basically code size neutral with a few tests coming in a byte or two heavier and others a byte or two lighter.
ca0367c
to
f4502a5
Compare
@@ -628,7 +631,7 @@ var LibraryBrowser = { | |||
Browser.resizeListeners.forEach((listener) => listener(canvas.width, canvas.height)); | |||
}, | |||
|
|||
setCanvasSize(width, height, noUpdates) { | |||
setCanvasSize(width, height, noUpdates = false) { |
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.
Is it better perhaps to use a closure annotation here instead, which would not add code size? (As this is safe - it is just that closure flags it as a possible bug, but here it isn't.)
If you want a third set of eyes on this, then @brendandahl is probably a better set. |
for (var i = 0; i < JSEvents.eventHandlers.length; ++i) { | ||
if (JSEvents.eventHandlers[i].target == target && | ||
(!eventTypeString || eventTypeString == JSEvents.eventHandlers[i].eventTypeString)) { | ||
if (JSEvents.eventHandlers[i].target) { |
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.
Shouldn't this be JSEvents.eventHandlers[i].target == target
?
mode = mode !== undefined ? mode : 438 /* 0666 */; | ||
mode &= {{{ cDefs.S_IALLUGO }}}; | ||
mode |= {{{ cDefs.S_IFREG }}}; | ||
return FS.mknod(path, mode, 0); | ||
}, | ||
mkdir(path, mode) { | ||
mkdir(path, mode = 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.
Does Closure optimize these = undefined
away?
For some reason closure doesn't report these real issues in the current configuration but they show up in the
MODULARIZE_INSTANCE
configuration that I'm working on.Most of these issues consist of adding default parameters to functions declared on objects such as
FS
.In addition there are a couple of other changes that are all real fixes:
canvasResizedCallbackTargetThread
removed sinceJSEvents.getTargetThreadForEventCallback()
will always return undefined when called with no argumentsreturn number rather than a boolean.
This change is basically code size neutral with a few tests coming in a byte or two heavier and others a byte or two lighter.