Skip to content

Commit

Permalink
refactor: remove old types
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Aug 29, 2023
1 parent 19a2b29 commit 565131c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
7 changes: 2 additions & 5 deletions packages/core/src/query/prepareSendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import {
prepareSendTransaction,
} from '../actions/prepareSendTransaction.js'
import type { Config } from '../createConfig.js'
import type { UnionPartialBy } from '../types/utils.js'
import type { UnionPartial } from '../types/utils.js'
import type { ScopeKeyParameter } from './types.js'
import { filterQueryOptions } from './utils.js'

export type PrepareSendTransactionOptions<
config extends Config,
chainId extends config['chains'][number]['id'],
> = UnionPartialBy<
PrepareSendTransactionParameters<config, chainId>,
keyof PrepareSendTransactionParameters
> &
> = UnionPartial<PrepareSendTransactionParameters<config, chainId>> &
ScopeKeyParameter

export function prepareSendTransactionQueryOptions<
Expand Down
27 changes: 7 additions & 20 deletions packages/core/src/types/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export type DistributedKeys<type> = type extends infer member
? keyof member
: never

/** Combines members of an intersection into a readable type. */
// https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
export type Evaluate<type> = { [key in keyof type]: type[key] } & unknown
Expand Down Expand Up @@ -71,31 +67,22 @@ export type PartialBy<type, key extends keyof type> = ExactPartial<
> &
Omit<type, key>

///////////////////////////////////////////////////////////////////////////
// Loose types

/** Loose version of {@link Omit} */
export type LooseOmit<type, keys extends string> = Pick<
type,
Exclude<keyof type, keys>
>

/** Loose version of {@link Pick} */
export type LoosePick<type, key extends string> = {
[p in key]: p extends keyof type ? type[p] : never
}

/** Loose version of {@link PartialBy} */
export type LoosePartialBy<type, key extends string> = ExactPartial<
LoosePick<type, key>
> &
LooseOmit<type, key>

export type UnionPartialBy<T, K extends keyof any> = T extends any
? LoosePartialBy<T, K extends string ? K : never>
: never

export type UnionPartial<type> = type extends object ? Partial<type> : type
///////////////////////////////////////////////////////////////////////////
// Union types

export type UnionEvaluate<type> = type extends object ? Evaluate<type> : type

export type UnionOmit<type, keys extends keyof type> = type extends any
? Omit<type, keys>
: never

export type UnionPartial<type> = type extends object ? Partial<type> : type

1 comment on commit 565131c

@vercel
Copy link

@vercel vercel bot commented on 565131c Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wagmi-v2 – ./docs

wagmi-v2.vercel.app
alpha.wagmi.sh
wagmi-v2-wagmi-dev.vercel.app
wagmi-v2-git-alpha-wagmi-dev.vercel.app

Please sign in to comment.