fix Diff ui types

This commit is contained in:
Sebastian Sdorra
2019-07-30 10:01:00 +02:00
parent 0b76cb7ea5
commit bbdc5a1989
4 changed files with 16 additions and 9 deletions

View File

@@ -1,10 +1,10 @@
//@flow
import React from "react";
import DiffFile from "./DiffFile";
import type { DiffObjectProps } from "./DiffTypes";
import type { DiffObjectProps, File } from "./DiffTypes";
type Props = DiffObjectProps & {
diff: any
diff: File[]
};
class Diff extends React.Component<Props> {

View File

@@ -27,12 +27,17 @@ export type Hunk = {
content: string
};
export type ChangeType = "insert" | "delete" | "normal";
export type Change = {
content: string,
isNormal: boolean,
newLineNumber: number,
oldLineNumber: number,
type: string
isNormal?: boolean,
isInsert?: boolean,
isDelete?: boolean,
lineNumber?: number,
newLineNumber?: number,
oldLineNumber?: number,
type: ChangeType
};
export type BaseContext = {

View File

@@ -6,14 +6,14 @@ import parser from "gitdiff-parser";
import Loading from "../Loading";
import Diff from "./Diff";
import type {DiffObjectProps} from "./DiffTypes";
import type {DiffObjectProps, File} from "./DiffTypes";
type Props = DiffObjectProps & {
url: string
};
type State = {
diff?: any,
diff?: File[],
loading: boolean,
error?: Error
};
@@ -47,7 +47,8 @@ class LoadingDiff extends React.Component<Props, State> {
.get(url)
.then(response => response.text())
.then(parser.parse)
.then(diff => {
// $FlowFixMe
.then((diff: File[]) => {
this.setState({
loading: false,
diff: diff

View File

@@ -12,6 +12,7 @@ export type {
FileChangeType,
Hunk,
Change,
ChangeType,
BaseContext,
AnnotationFactory,
AnnotationFactoryContext,