refactor: move type utils to shared

This commit is contained in:
Evan You
2022-01-16 15:43:19 +08:00
parent 2e3e183b4f
commit 6cfd72e760
6 changed files with 10 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ export * from './domAttrConfig'
export * from './escapeHtml'
export * from './looseEqual'
export * from './toDisplayString'
export * from './typeUtils'
export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__
? Object.freeze({})

View File

@@ -0,0 +1,10 @@
export type UnionToIntersection<U> = (
U extends any ? (k: U) => void : never
) extends (k: infer I) => void
? I
: never
// make keys required but keep undefined values
export type LooseRequired<T> = { [P in string & keyof T]: T[P] }
export type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N