Skip to content

Commit fe19ae5

Browse files
committed
Improve type by providing ChangeType and FileType as exported types
1 parent f7b866e commit fe19ae5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ gitDiffParser.parse(gitDiffText);
2121
### API
2222

2323
```ts
24+
export type ChangeType = 'insert' | 'delete' | 'normal';
25+
2426
export interface Change {
2527
content: string;
26-
type: 'insert' | 'delete' | 'normal';
28+
type: ChangeType;
2729
isInsert?: boolean;
2830
isDelete?: boolean;
2931
isNormal?: boolean;
@@ -41,6 +43,8 @@ export interface Hunk {
4143
changes: Change[];
4244
}
4345

46+
export type FileType = 'add' | 'delete' | 'modify' | 'rename' | 'copy';
47+
4448
export interface File {
4549
hunks: Hunk[];
4650
oldEndingNewLine: boolean;
@@ -53,7 +57,7 @@ export interface File {
5357
oldPath: string;
5458
newPath: string;
5559
isBinary?: boolean;
56-
type: 'add' | 'delete' | 'modify''rename';
60+
type: FileType;
5761
}
5862

5963
export function parse(source: string): File[];

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
export type ChangeType = 'insert' | 'delete' | 'normal';
2+
13
export interface Change {
24
content: string;
3-
type: 'insert' | 'delete' | 'normal';
5+
type: ChangeType;
46
isInsert?: boolean;
57
isDelete?: boolean;
68
isNormal?: boolean;
@@ -18,6 +20,8 @@ export interface Hunk {
1820
changes: Change[];
1921
}
2022

23+
export type FileType = 'add' | 'delete' | 'modify' | 'rename' | 'copy';
24+
2125
export interface File {
2226
hunks: Hunk[];
2327
oldEndingNewLine: boolean;
@@ -30,7 +34,7 @@ export interface File {
3034
oldPath: string;
3135
newPath: string;
3236
isBinary?: boolean;
33-
type: 'add' | 'delete' | 'modify' | 'rename' | 'copy';
37+
type: FileType;
3438
}
3539

3640
export function parse(source: string): File[];

0 commit comments

Comments
 (0)