Open Bug 1574194 Opened 5 years ago Updated 2 years ago

Require explicitly inexact Flowtype object types.

Categories

(DevTools :: Debugger, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: loganfsmyth, Unassigned)

References

(Blocks 1 open bug)

Details

Flow currently has "inexact" and "exact" object types, where exact objects must have exactly the fields given in the type, and inexact objects must have those fields, but are also allowed to have additional properties.

The common syntax is

type SomeExactObj = {| prop: string |};
type SomeInexactObj = { prop: string };

but in fact, the Flow team eventually wants to make { prop: string } exact by default. (https://medium.com/flow-type/on-the-roadmap-exact-objects-by-default-16b72933c5cf) Along the path to this eventual goal, they have added a new "..." token to mark an object inexact:

type SomeInexactObj = { prop: string, ... };

We should update our codebase to require ... for all types that aren't exact. That should mean

  1. Enabling https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-require-inexact-type
  2. Fixing all of the places in the codebase that are inexact but don't have ...

I would recommend approaching this bug with a few steps

  1. Figure out what we need to do to enable eslint-plugin-flowtype in mozilla-central, since right now it is not an ESLint plugin that we load.
  2. Instead of manually fixing every instance of an inexact object, use this as motivation to submit a patch to eslint-plugin-flowtype to use ESlint's autofix framework to fix all the issues for you, that way you can run ESLint with --fix to update all the debugger code.
  3. Submit a patch adding ... everywhere.
Priority: -- → P3
Blocks: node-dx
Severity: normal normal → S3 S3
You need to log in before you can comment on or make changes to this bug.