Page MenuHomePhabricator

[Flow202][web][skip-ci] [19/x] Fix Flow issues around untyped this parameter
ClosedPublic

Authored by ashoat on Nov 8 2023, 11:43 AM.
Tags
None
Referenced Files
F3369637: D9785.id32971.diff
Mon, Nov 25, 11:02 PM
Unknown Object (File)
Mon, Nov 25, 12:13 AM
Unknown Object (File)
Sun, Nov 24, 8:12 PM
Unknown Object (File)
Fri, Nov 22, 10:05 PM
Unknown Object (File)
Fri, Nov 22, 6:33 PM
Unknown Object (File)
Sun, Nov 17, 12:46 AM
Unknown Object (File)
Sat, Nov 16, 4:37 AM
Unknown Object (File)
Sun, Oct 27, 9:02 PM
Subscribers

Details

Summary

The new version of Flow wants us to type the this parameter in naked function declarations.

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ media/image-utils.js:20:33

Missing an annotation on implicit this parameter of function. [missing-this-annot]

     17│
     18│ function getEXIFOrientation(file: File): Promise<?number> {
     19│   return new Promise(resolve => {
     20│     EXIF.getData(file, function () {
     21│       resolve(EXIF.getTag(this, 'Orientation'));
     22│     });
     23│   });

To type this, Flow has a somewhat weird syntax where we list this as a parameter. This confuses ESLint, so I had to add an eslint-disable line as well.

NOTE: CI will fail on this diff. I considered the possibility of fixing Flow errors BEFORE upgrading Flow, but it wasn't possible... in some cases, the fixes to support the new version of Flow caused errors in the old version. I could have hidden these type errors with $FlowFixMe lines and then later revert those, but that seemed like too much busy work.

Depends on D9784

Test Plan

Confirm the Flow errors go away

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 8 2023, 12:10 PM
Harbormaster failed remote builds in B23933: Diff 32971!
tomek added inline comments.
web/media/image-utils.js
20–21 ↗(On Diff #32971)

According to https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e

using Flow after this change will require updating to a version of Babel that has support for this new syntax: at least version 7.13.0

But it seems we're already on this version on master.

This revision is now accepted and ready to land.Nov 9 2023, 3:24 AM
ashoat retitled this revision from [Flow202][web] [19/x] Fix Flow issues around untyped this parameter to [Flow202][web][skip-ci] [19/x] Fix Flow issues around untyped this parameter.Nov 19 2023, 5:04 PM
This revision was landed with ongoing or failed builds.Nov 27 2023, 3:26 PM
This revision was automatically updated to reflect the committed changes.