Skip to content

Commit

Permalink
perf(ts): add variance annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Jun 15, 2022
1 parent f053e76 commit cecc9db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/types/merging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
export interface DeepMergeMergeFunctionURItoKind<
Ts extends ReadonlyArray<unknown>,
MF extends DeepMergeMergeFunctionsURIs,
M
in out M
> {
readonly DeepMergeLeafURI: DeepMergeLeaf<Ts>;
readonly DeepMergeRecordsDefaultURI: DeepMergeRecordsDefaultHKT<Ts, MF, M>;
Expand Down
13 changes: 8 additions & 5 deletions src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ import type { DeepMergeBuiltInMetaData } from "./merging";
* The options the user can pass to customize deepmerge.
*/
export type DeepMergeOptions<
M,
in out M,
MM extends Readonly<Record<PropertyKey, unknown>> = DeepMergeBuiltInMetaData
> = Partial<DeepMergeOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;

type MetaDataUpdater<M, MM extends DeepMergeBuiltInMetaData> = (
type MetaDataUpdater<in out M, MM extends DeepMergeBuiltInMetaData> = (
previousMeta: M | undefined,
metaMeta: Readonly<Partial<MM>>
) => M;

/**
* All the options the user can pass to customize deepmerge.
*/
type DeepMergeOptionsFull<M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
type DeepMergeOptionsFull<
in out M,
MM extends DeepMergeBuiltInMetaData
> = Readonly<{
mergeRecords: DeepMergeMergeFunctions<M, MM>["mergeRecords"] | false;
mergeArrays: DeepMergeMergeFunctions<M, MM>["mergeArrays"] | false;
mergeMaps: DeepMergeMergeFunctions<M, MM>["mergeMaps"] | false;
Expand All @@ -33,7 +36,7 @@ type DeepMergeOptionsFull<M, MM extends DeepMergeBuiltInMetaData> = Readonly<{
* All the merge functions that deepmerge uses.
*/
type DeepMergeMergeFunctions<
M,
in M,
MM extends DeepMergeBuiltInMetaData
> = Readonly<{
mergeRecords: <
Expand Down Expand Up @@ -86,7 +89,7 @@ type DeepMergeMergeFunctions<
* The utils provided to the merge functions.
*/
export type DeepMergeMergeFunctionUtils<
M,
in out M,
MM extends DeepMergeBuiltInMetaData
> = Readonly<{
mergeFunctions: DeepMergeMergeFunctions<M, MM>;
Expand Down

0 comments on commit cecc9db

Please sign in to comment.