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)
Thu, Nov 14, 4:33 AM
Unknown Object (File)
Tue, Nov 12, 12:24 AM
Unknown Object (File)
Tue, Nov 12, 12:24 AM
Unknown Object (File)
Tue, Nov 12, 12:24 AM
Unknown Object (File)
Tue, Nov 12, 12:24 AM
Unknown Object (File)
Tue, Nov 12, 12:24 AM
Unknown Object (File)
Fri, Nov 8, 8:24 PM
Unknown Object (File)
Wed, Nov 6, 9:28 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
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

desktop/flow-typed/npm/electron_v22.0.0.js
217 ↗(On Diff #21139)

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 ↗(On Diff #21139)

The doc says that

On Windows only releaseName is available.

So maybe other props should be marked as optional?

217 ↗(On Diff #21139)

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 ↗(On Diff #21139)

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.