Page MenuHomePhabricator

[desktop] Add additional types for electron auto updating
ClosedPublic

Authored by michal on Jan 20 2023, 4:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 13, 5:03 AM
Unknown Object (File)
Apr 17 2024, 9:48 AM
Unknown Object (File)
Apr 17 2024, 9:48 AM
Unknown Object (File)
Apr 17 2024, 9:48 AM
Unknown Object (File)
Apr 17 2024, 9:48 AM
Unknown Object (File)
Apr 17 2024, 9:47 AM
Unknown Object (File)
Apr 17 2024, 9:41 AM
Unknown Object (File)
Mar 12 2024, 11:25 PM
Subscribers

Details

Summary

This diff adds types for autoUpdater module and other properties used in the later diffs. They are taken from the official electron documentation. Documentation

Test Plan

Run flow in the desktop workspace. Also run flow including diffs later on in the stack

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

desktop/flow-typed/npm/electron_v22.0.0.js
217

This can be assigned to return a value from the callback, so I've removed the read-only modifier.

tomek added inline comments.
desktop/flow-typed/npm/electron_v22.0.0.js
188–192

The doc says that

On Windows only releaseName is available.

So maybe other props should be marked as optional?

217

Not really sure about this change. It depends on the usage, but we should be able to keep this read only and construct a new object / assign a type just before the return. But it's also possible that the purpose is to return the value by mutating an argument - this is an ugly pattern, but if the lib works that way, we have to reflect that in the types.

This revision is now accepted and ready to land.Jan 26 2023, 3:50 AM

Marked props available only on macOS as optional, thanks for catching that. I've also added a few additional events, because I will be using some of them in the next diffs.

desktop/flow-typed/npm/electron_v22.0.0.js
217

But it's also possible that the purpose is to return the value by mutating an argument - this is an ugly pattern, but if the lib works that way, we have to reflect that in the types.

Yeah, that's how it works for sync communication, unfortunately.
ipcMain.on('event', ev => {ev.returnValue = 123;});

After more testing it seems that autoUpdater methods have to be binded to the object so I've changed the typings from type to class.