Page MenuHomePhabricator

[Flow202][web][skip-ci] [5/x] Address missing-local-annot type errors
ClosedPublic

Authored by ashoat on Nov 8 2023, 11:33 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 7, 8:18 AM
Unknown Object (File)
Mon, Apr 29, 6:47 AM
Unknown Object (File)
Tue, Apr 16, 3:21 AM
Unknown Object (File)
Apr 13 2024, 8:28 AM
Unknown Object (File)
Apr 11 2024, 8:02 AM
Unknown Object (File)
Apr 9 2024, 5:17 AM
Unknown Object (File)
Apr 8 2024, 1:35 AM
Unknown Object (File)
Apr 8 2024, 1:35 AM
Subscribers

Details

Summary

The new version of Flow wants more annotations for function and member definitions. This diff adds all of the required annotations to the web codebase necessary to clear all missing-local-annot errors. The lib equivalent of this diff is D9697.

I also included some other changes where I type function params that were yielding other Flow errors (different from missing-local-annot).

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 D9770

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, 11:44 AM
Harbormaster failed remote builds in B23919: Diff 32957!
tomek added inline comments.
web/account/traditional-login-form.react.js
50 ↗(On Diff #32957)

Do we still need this invariant?

web/chat/chat-input-bar.react.js
169 ↗(On Diff #32957)

According to https://flow.org/en/docs/types/arrays/#toc-array-type-shorthand-syntax

There is an alternative to the Array<T> syntax: T[]. This syntax is discouraged and may be deprecated in the future.

This revision is now accepted and ready to land.Nov 9 2023, 3:06 AM
web/account/traditional-login-form.react.js
50 ↗(On Diff #32957)

Yes – currentTarget is typed based on the type param (HTMLInputElement), but target isn't because for some SyntheticEvents, the target can be an element nested within the element where is the listener is attached. This doesn't apply in our case since we're not nesting any elements inside the <input>

(I suspect we could switch these to currentTarget, but I don't have the cycles to test that change across the codebase right now)

web/chat/chat-input-bar.react.js
169 ↗(On Diff #32957)

Thanks for linking – didn't know that it's discouraged. I tend to avoid it for more complicated types, but I've been using it for simple ones like string[]

Replace string[] with Array<string>

ashoat retitled this revision from [Flow202][web] [5/x] Address missing-local-annot type errors to [Flow202][web][skip-ci] [5/x] Address missing-local-annot type errors.Nov 19 2023, 5:01 PM