Skip to content

Commit

Permalink
fix(type): fix type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Jan 31, 2023
1 parent a3c39de commit 557d56b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,25 @@ export interface ProxyDraft<T = any> {
callbacks?: ((patches?: Patches, inversePatches?: Patches) => void)[];
}

export type Patch<P extends PatchesOptions = any> = {
op: typeof Operation[keyof typeof Operation];
path: P extends { pathAsArray: false } ? string : (string | number)[];
value?: any;
};
export type Patch<P extends PatchesOptions = any> = P extends {
pathAsArray: false;
}
? {
op: typeof Operation[keyof typeof Operation];
path: string;
value?: any;
}
: P extends true | object
? {
op: typeof Operation[keyof typeof Operation];
path: (string | number)[];
value?: any;
}
: {
op: typeof Operation[keyof typeof Operation];
path: string | (string | number)[];
value?: any;
};

export type Patches<P extends PatchesOptions = any> = Patch<P>[];

Expand Down

0 comments on commit 557d56b

Please sign in to comment.