Skip to content

Commit

Permalink
Avoid forward references in commitUtils types
Browse files Browse the repository at this point in the history
Summary:
The resulting types less logically structured (as discussed), but while
Flow considers them equivalent, the linter does not—and, more
importantly, the runtime `PropTypes` are not generated correctly when
forward-uses are in play, due to the following issue:

brigand/babel-plugin-flow-react-proptypes#185

I _think_ this is the lesser of two evils—but am happy to be convinced
otherwise.

Test Plan:
Note that `yarn flow` and `yarn test` are both fine, and `yarn start`
has no lint errors or runtime errors. Note further that when reverting
`insertions → added` and `deletions → deleted`, there are prop-type
errors in both `yarn test` and `yarn start`. (Without the permutation of
the types, this does not occur.)

wchargin-branch: avoid-forward-references
  • Loading branch information
wchargin committed Feb 18, 2018
1 parent cb8ba0e commit 8f26f4f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions explorer/src/commitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@

import PropTypes from "prop-types";

export type CommitData = {
// TODO improve variable names
fileToCommits: {[filename: string]: string[]},
commits: {[commithash: string]: Commit},
type FileStats = {
lines: number,
insertions: number,
deletions: number,
};

type Commit = {
author: string,
stats: {[filename: string]: FileStats},
};

type FileStats = {
lines: number,
added: number,
deleted: number,
export type CommitData = {
// TODO improve variable names
fileToCommits: {[filename: string]: string[]},
commits: {[commithash: string]: Commit},
};

export function commitWeight(commit: Commit, filepath: string): number {
Expand Down

0 comments on commit 8f26f4f

Please sign in to comment.