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

@@ -8,7 +8,8 @@ import {
isArray,
isFunction,
isOn,
toNumber
toNumber,
UnionToIntersection
} from '@vue/shared'
import {
ComponentInternalInstance,
@@ -18,7 +19,6 @@ import {
} from './component'
import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling'
import { warn } from './warning'
import { UnionToIntersection } from './helpers/typeUtils'
import { devtoolsComponentEmit } from './devtools'
import { AppContext } from './apiCreateApp'
import { emit as compatInstanceEmit } from './compat/instanceEventEmitter'

View File

@@ -15,7 +15,9 @@ import {
isObject,
isArray,
NOOP,
isPromise
isPromise,
LooseRequired,
UnionToIntersection
} from '@vue/shared'
import { computed, isRef, Ref } from '@vue/reactivity'
import {
@@ -60,7 +62,6 @@ import {
import { warn } from './warning'
import { VNodeChild } from './vnode'
import { callWithAsyncErrorHandling } from './errorHandling'
import { LooseRequired, UnionToIntersection } from './helpers/typeUtils'
import { deepMergeData } from './compat/data'
import { DeprecationTypes } from './compat/compatConfig'
import {

View File

@@ -21,7 +21,8 @@ import {
EMPTY_ARR,
def,
extend,
isOn
isOn,
IfAny
} from '@vue/shared'
import { warn } from './warning'
import {
@@ -39,7 +40,6 @@ import { createPropsDefaultThis } from './compat/props'
import { isCompatEnabled, softAssertCompatEnabled } from './compat/compatConfig'
import { DeprecationTypes } from './compat/compatConfig'
import { shouldSkipAttr } from './compat/attrsFallthrough'
import { IfAny } from './helpers/typeUtils'
export type ComponentPropsOptions<P = Data> =
| ComponentObjectPropsOptions<P>

View File

@@ -13,7 +13,8 @@ import {
NOOP,
extend,
isString,
isFunction
isFunction,
UnionToIntersection
} from '@vue/shared'
import {
toRaw,
@@ -40,7 +41,6 @@ import { Slots } from './componentSlots'
import { markAttrsAccessed } from './componentRenderUtils'
import { currentRenderingInstance } from './componentRenderContext'
import { warn } from './warning'
import { UnionToIntersection } from './helpers/typeUtils'
import { installCompatInstanceProperties } from './compat/instance'
/**

View File

@@ -1,10 +0,0 @@
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