chore: run updated prettier

This commit is contained in:
Evan You
2021-07-19 18:24:18 -04:00
parent 69344ff1ae
commit 47f488350c
110 changed files with 695 additions and 698 deletions

View File

@@ -71,42 +71,43 @@ export function defineAsyncComponent<
let thisRequest: Promise<ConcreteComponent>
return (
pendingRequest ||
(thisRequest = pendingRequest = loader()
.catch(err => {
err = err instanceof Error ? err : new Error(String(err))
if (userOnError) {
return new Promise((resolve, reject) => {
const userRetry = () => resolve(retry())
const userFail = () => reject(err)
userOnError(err, userRetry, userFail, retries + 1)
})
} else {
throw err
}
})
.then((comp: any) => {
if (thisRequest !== pendingRequest && pendingRequest) {
return pendingRequest
}
if (__DEV__ && !comp) {
warn(
`Async component loader resolved to undefined. ` +
`If you are using retry(), make sure to return its return value.`
)
}
// interop module default
if (
comp &&
(comp.__esModule || comp[Symbol.toStringTag] === 'Module')
) {
comp = comp.default
}
if (__DEV__ && comp && !isObject(comp) && !isFunction(comp)) {
throw new Error(`Invalid async component load result: ${comp}`)
}
resolvedComp = comp
return comp
}))
(thisRequest = pendingRequest =
loader()
.catch(err => {
err = err instanceof Error ? err : new Error(String(err))
if (userOnError) {
return new Promise((resolve, reject) => {
const userRetry = () => resolve(retry())
const userFail = () => reject(err)
userOnError(err, userRetry, userFail, retries + 1)
})
} else {
throw err
}
})
.then((comp: any) => {
if (thisRequest !== pendingRequest && pendingRequest) {
return pendingRequest
}
if (__DEV__ && !comp) {
warn(
`Async component loader resolved to undefined. ` +
`If you are using retry(), make sure to return its return value.`
)
}
// interop module default
if (
comp &&
(comp.__esModule || comp[Symbol.toStringTag] === 'Module')
) {
comp = comp.default
}
if (__DEV__ && comp && !isObject(comp) && !isFunction(comp)) {
throw new Error(`Invalid async component load result: ${comp}`)
}
resolvedComp = comp
return comp
}))
)
}

View File

@@ -133,7 +133,7 @@ export interface AppContext {
type PluginInstallFunction = (app: App, ...options: any[]) => any
export type Plugin =
| PluginInstallFunction & { install?: PluginInstallFunction }
| (PluginInstallFunction & { install?: PluginInstallFunction })
| {
install: PluginInstallFunction
}

View File

@@ -63,12 +63,12 @@ export function injectHook(
}
}
export const createHook = <T extends Function = () => any>(
lifecycle: LifecycleHooks
) => (hook: T, target: ComponentInternalInstance | null = currentInstance) =>
// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
(!isInSSRComponentSetup || lifecycle === LifecycleHooks.SERVER_PREFETCH) &&
injectHook(lifecycle, hook, target)
export const createHook =
<T extends Function = () => any>(lifecycle: LifecycleHooks) =>
(hook: T, target: ComponentInternalInstance | null = currentInstance) =>
// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
(!isInSSRComponentSetup || lifecycle === LifecycleHooks.SERVER_PREFETCH) &&
injectHook(lifecycle, hook, target)
export const onBeforeMount = createHook(LifecycleHooks.BEFORE_MOUNT)
export const onMounted = createHook(LifecycleHooks.MOUNTED)

View File

@@ -130,12 +130,12 @@ export function defineExpose(exposed?: Record<string, any>) {
type NotUndefined<T> = T extends undefined ? never : T
type InferDefaults<T> = {
[K in keyof T]?: NotUndefined<T[K]> extends (
[K in keyof T]?: NotUndefined<T[K]> extends
| number
| string
| boolean
| symbol
| Function)
| Function
? NotUndefined<T[K]>
: (props: T) => NotUndefined<T[K]>
}

View File

@@ -50,10 +50,14 @@ export type WatchCallback<V = any, OV = any> = (
type MapSources<T, Immediate> = {
[K in keyof T]: T[K] extends WatchSource<infer V>
? Immediate extends true ? (V | undefined) : V
? Immediate extends true
? V | undefined
: V
: T[K] extends object
? Immediate extends true ? (T[K] | undefined) : T[K]
: never
? Immediate extends true
? T[K] | undefined
: T[K]
: never
}
type InvalidateCbRegistrator = (cb: () => void) => void
@@ -81,9 +85,13 @@ export function watchPostEffect(
effect: WatchEffect,
options?: DebuggerOptions
) {
return doWatch(effect, null, (__DEV__
? Object.assign(options || {}, { flush: 'post' })
: { flush: 'post' }) as WatchOptionsBase)
return doWatch(
effect,
null,
(__DEV__
? Object.assign(options || {}, { flush: 'post' })
: { flush: 'post' }) as WatchOptionsBase
)
}
// initial value for watchers to trigger on undefined initial values
@@ -116,7 +124,7 @@ export function watch<
// overload: single source + cb
export function watch<T, Immediate extends Readonly<boolean> = false>(
source: WatchSource<T>,
cb: WatchCallback<T, Immediate extends true ? (T | undefined) : T>,
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
options?: WatchOptions<Immediate>
): WatchStopHandle
@@ -126,7 +134,7 @@ export function watch<
Immediate extends Readonly<boolean> = false
>(
source: T,
cb: WatchCallback<T, Immediate extends true ? (T | undefined) : T>,
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
options?: WatchOptions<Immediate>
): WatchStopHandle

View File

@@ -238,8 +238,9 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
[DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE]: {
message: componentName =>
`Component <${componentName ||
'Anonymous'}> has \`inheritAttrs: false\` but is ` +
`Component <${
componentName || 'Anonymous'
}> has \`inheritAttrs: false\` but is ` +
`relying on class/style fallthrough from parent. In Vue 3, class/style ` +
`are now included in $attrs and will no longer fallthrough when ` +
`inheritAttrs is false. If you are already using v-bind="$attrs" on ` +
@@ -317,9 +318,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`${name}="false" instead of removing it in Vue 3. To remove the attribute, ` +
`use \`null\` or \`undefined\` instead. If the usage is intended, ` +
`you can disable the compat behavior and suppress this warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.ATTR_FALSE_VALUE
}: false })\n`,
`\n\n configureCompat({ ${DeprecationTypes.ATTR_FALSE_VALUE}: false })\n`,
link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
},
@@ -332,9 +331,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`Always use explicit "true" or "false" values for enumerated attributes. ` +
`If the usage is intended, ` +
`you can disable the compat behavior and suppress this warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.ATTR_ENUMERATED_COERCION
}: false })\n`,
`\n\n configureCompat({ ${DeprecationTypes.ATTR_ENUMERATED_COERCION}: false })\n`,
link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
},
@@ -348,9 +345,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`default if no "tag" prop is specified. If you do not rely on the span ` +
`for styling, you can disable the compat behavior and suppress this ` +
`warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.TRANSITION_GROUP_ROOT
}: false })\n`,
`\n\n configureCompat({ ${DeprecationTypes.TRANSITION_GROUP_ROOT}: false })\n`,
link: `https://v3.vuejs.org/guide/migration/transition-group.html`
},
@@ -366,9 +361,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`usage and intend to use plain functions for functional components, ` +
`you can disable the compat behavior and suppress this ` +
`warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.COMPONENT_ASYNC
}: false })\n`
`\n\n configureCompat({ ${DeprecationTypes.COMPONENT_ASYNC}: false })\n`
)
},
link: `https://v3.vuejs.org/guide/migration/async-components.html`
@@ -394,9 +387,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
message: (comp: ComponentOptions) => {
const configMsg =
`opt-in to ` +
`Vue 3 behavior on a per-component basis with \`compatConfig: { ${
DeprecationTypes.COMPONENT_V_MODEL
}: false }\`.`
`Vue 3 behavior on a per-component basis with \`compatConfig: { ${DeprecationTypes.COMPONENT_V_MODEL}: false }\`.`
if (
comp.props &&
(isArray(comp.props)
@@ -421,9 +412,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
message:
`Vue 3's render function API has changed. ` +
`You can opt-in to the new API with:` +
`\n\n configureCompat({ ${
DeprecationTypes.RENDER_FUNCTION
}: false })\n` +
`\n\n configureCompat({ ${DeprecationTypes.RENDER_FUNCTION}: false })\n` +
`\n (This can also be done per-component via the "compatConfig" option.)`,
link: `https://v3.vuejs.org/guide/migration/render-function-api.html`
},
@@ -565,9 +554,7 @@ export function validateCompatConfig(
if (instance && config[DeprecationTypes.OPTIONS_DATA_MERGE] != null) {
warn(
`Deprecation config "${
DeprecationTypes.OPTIONS_DATA_MERGE
}" can only be configured globally.`
`Deprecation config "${DeprecationTypes.OPTIONS_DATA_MERGE}" can only be configured globally.`
)
}
}

View File

@@ -251,8 +251,8 @@ export function createCompatVue(
mergeBase[key] = isArray(superValue)
? superValue.slice()
: isObject(superValue)
? extend(Object.create(null), superValue)
: superValue
? extend(Object.create(null), superValue)
: superValue
}
SubVue.options = mergeOptions(

View File

@@ -177,7 +177,7 @@ const skipLegacyRootLevelProps = /*#__PURE__*/ makeMap(
function convertLegacyProps(
legacyProps: LegacyVNodeProps | undefined,
type: any
): Data & VNodeProps | null {
): (Data & VNodeProps) | null {
if (!legacyProps) {
return null
}

View File

@@ -51,7 +51,7 @@ export function legacyBindObjectProps(
if (isSync) {
const on = data.on || (data.on = {})
on[`update:${key}`] = function($event: any) {
on[`update:${key}`] = function ($event: any) {
value[key] = $event
}
}

View File

@@ -761,10 +761,8 @@ export function finishComponentSetup(
startMeasure(instance, `compile`)
}
const { isCustomElement, compilerOptions } = instance.appContext.config
const {
delimiters,
compilerOptions: componentCompilerOptions
} = Component
const { delimiters, compilerOptions: componentCompilerOptions } =
Component
const finalCompilerOptions: CompilerOptions = extend(
extend(
{
@@ -822,10 +820,10 @@ export function finishComponentSetup(
(__ESM_BUNDLER__
? ` Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".`
: __ESM_BROWSER__
? ` Use "vue.esm-browser.js" instead.`
: __GLOBAL__
? ` Use "vue.global.js" instead.`
: ``) /* should not happen */
? ` Use "vue.esm-browser.js" instead.`
: __GLOBAL__
? ` Use "vue.global.js" instead.`
: ``) /* should not happen */
)
} else {
warn(`Component is missing template or render function.`)

View File

@@ -77,7 +77,9 @@ type RequiredKeys<T> = {
// don't mark Boolean props as undefined
| BooleanConstructor
| { type: BooleanConstructor }
? T[K] extends { default: undefined | (() => undefined) } ? never : K
? T[K] extends { default: undefined | (() => undefined) }
? never
: K
: never
}[keyof T]
@@ -98,16 +100,18 @@ type DefaultKeys<T> = {
type InferPropType<T> = [T] extends [null]
? any // null & true would fail to infer
: [T] extends [{ type: null | true }]
? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean`
: [T] extends [ObjectConstructor | { type: ObjectConstructor }]
? Record<string, any>
: [T] extends [BooleanConstructor | { type: BooleanConstructor }]
? boolean
: [T] extends [DateConstructor | { type: DateConstructor }]
? Date
: [T] extends [Prop<infer V, infer D>]
? (unknown extends V ? D : V)
: T
? any // As TS issue https://github.com/Microsoft/TypeScript/issues/14829 // somehow `ObjectConstructor` when inferred from { (): T } becomes `any` // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean`
: [T] extends [ObjectConstructor | { type: ObjectConstructor }]
? Record<string, any>
: [T] extends [BooleanConstructor | { type: BooleanConstructor }]
? boolean
: [T] extends [DateConstructor | { type: DateConstructor }]
? Date
: [T] extends [Prop<infer V, infer D>]
? unknown extends V
? D
: V
: T
export type ExtractPropTypes<O> = O extends object
? { [K in keyof O]?: unknown } & // This is needed to keep the relation between the option prop and the props, allowing to use ctrl+click to navigate to the prop options. see: #3656
@@ -407,7 +411,7 @@ function resolvePropValue(
setCurrentInstance(instance)
value = propsDefaults[key] = defaultValue.call(
__COMPAT__ &&
isCompatEnabled(DeprecationTypes.PROPS_DEFAULT_THIS, instance)
isCompatEnabled(DeprecationTypes.PROPS_DEFAULT_THIS, instance)
? createPropsDefaultThis(instance, props, key)
: null,
props

View File

@@ -72,7 +72,9 @@ import { installCompatInstanceProperties } from './compat/instance'
export interface ComponentCustomProperties {}
type IsDefaultMixinComponent<T> = T extends ComponentOptionsMixin
? ComponentOptionsMixin extends T ? true : false
? ComponentOptionsMixin extends T
? true
: false
: false
type MixinToOptionTypes<T> = T extends ComponentOptionsBase<
@@ -261,15 +263,8 @@ export interface ComponentRenderContext {
export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
get({ _: instance }: ComponentRenderContext, key: string) {
const {
ctx,
setupState,
data,
props,
accessCache,
type,
appContext
} = instance
const { ctx, setupState, data, props, accessCache, type, appContext } =
instance
// for internal formatters to know that this is a Vue instance
if (__DEV__ && key === '__isVue') {

View File

@@ -257,7 +257,7 @@ if (__COMPAT__) {
// export the public type for h/tsx inference
// also to avoid inline import() in generated d.ts files
export const BaseTransition = (BaseTransitionImpl as any) as {
export const BaseTransition = BaseTransitionImpl as any as {
new (): {
$props: BaseTransitionProps<any>
}

View File

@@ -329,7 +329,7 @@ if (__COMPAT__) {
// export the public type for h/tsx inference
// also to avoid inline import() in generated d.ts files
export const KeepAlive = (KeepAliveImpl as any) as {
export const KeepAlive = KeepAliveImpl as any as {
__isKeepAlive: true
new (): {
$props: VNodeProps & KeepAliveProps

View File

@@ -87,9 +87,7 @@ export const SuspenseImpl = {
}
// Force-casted public typing for h and TSX props inference
export const Suspense = ((__FEATURE_SUSPENSE__
? SuspenseImpl
: null) as any) as {
export const Suspense = (__FEATURE_SUSPENSE__ ? SuspenseImpl : null) as any as {
__isSuspense: true
new (): { $props: VNodeProps & SuspenseProps }
}
@@ -520,13 +518,8 @@ function createSuspenseBoundary(
return
}
const {
vnode,
activeBranch,
parentComponent,
container,
isSVG
} = suspense
const { vnode, activeBranch, parentComponent, container, isSVG } =
suspense
// invoke @fallback event
triggerEvent(vnode, 'onFallback')

View File

@@ -371,7 +371,7 @@ function hydrateTeleport(
}
// Force-casted public typing for h and TSX props inference
export const Teleport = (TeleportImpl as any) as {
export const Teleport = TeleportImpl as any as {
__isTeleport: true
new (): { $props: VNodeProps & TeleportProps }
}

View File

@@ -54,13 +54,11 @@ export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook(
DevtoolsHooks.COMPONENT_ADDED
)
export const devtoolsComponentUpdated = /*#__PURE__*/ createDevtoolsComponentHook(
DevtoolsHooks.COMPONENT_UPDATED
)
export const devtoolsComponentUpdated =
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_UPDATED)
export const devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
DevtoolsHooks.COMPONENT_REMOVED
)
export const devtoolsComponentRemoved =
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_REMOVED)
function createDevtoolsComponentHook(hook: DevtoolsHooks) {
return (component: ComponentInternalInstance) => {

View File

@@ -15,7 +15,8 @@ export function createSlots(
dynamicSlots: (
| CompiledSlotDescriptor
| CompiledSlotDescriptor[]
| undefined)[]
| undefined
)[]
): Record<string, Slot> {
for (let i = 0; i < dynamicSlots.length; i++) {
const slot = dynamicSlots[i]

View File

@@ -1,6 +1,6 @@
export type UnionToIntersection<U> = (U extends any
? (k: U) => void
: never) extends ((k: infer I) => void)
export type UnionToIntersection<U> = (
U extends any ? (k: U) => void : never
) extends (k: infer I) => void
? I
: never

View File

@@ -31,10 +31,10 @@ if (__DEV__) {
typeof global !== 'undefined'
? global
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: {}
? self
: typeof window !== 'undefined'
? window
: {}
globalObject.__VUE_HMR_RUNTIME__ = {
createRecord: tryWrap(createRecord),

View File

@@ -280,8 +280,8 @@ export function createHydrationFunctions(
if (
forcePatchValue ||
!optimized ||
(patchFlag & PatchFlags.FULL_PROPS ||
patchFlag & PatchFlags.HYDRATE_EVENTS)
patchFlag & PatchFlags.FULL_PROPS ||
patchFlag & PatchFlags.HYDRATE_EVENTS
) {
for (const key in props) {
if (
@@ -346,7 +346,9 @@ export function createHydrationFunctions(
hasMismatch = true
__DEV__ &&
warn(
`Hydration text content mismatch in <${vnode.type as string}>:\n` +
`Hydration text content mismatch in <${
vnode.type as string
}>:\n` +
`- Client: ${el.textContent}\n` +
`- Server: ${vnode.children as string}`
)
@@ -465,8 +467,8 @@ export function createHydrationFunctions(
node.nodeType === DOMNodeTypes.TEXT
? `(text)`
: isComment(node) && node.data === '['
? `(start of fragment)`
: ``
? `(start of fragment)`
: ``
)
vnode.el = null

View File

@@ -341,9 +341,9 @@ const _compatUtils = {
/**
* @internal only exposed in compat builds.
*/
export const compatUtils = (__COMPAT__
? _compatUtils
: null) as typeof _compatUtils
export const compatUtils = (
__COMPAT__ ? _compatUtils : null
) as typeof _compatUtils
// Ref macros ------------------------------------------------------------------
// for dts generation only

View File

@@ -1444,7 +1444,7 @@ function baseCreateRenderer(
}
if (isAsyncWrapper(initialVNode)) {
(initialVNode.type as ComponentOptions).__asyncLoader!().then(
;(initialVNode.type as ComponentOptions).__asyncLoader!().then(
// note: we are moving the render call into an async callback,
// which means it won't track dependencies - but it's ok because
// a server-rendered async wrapper is already in resolved state
@@ -2406,10 +2406,9 @@ function baseCreateRenderer(
let hydrate: ReturnType<typeof createHydrationFunctions>[0] | undefined
let hydrateNode: ReturnType<typeof createHydrationFunctions>[1] | undefined
if (createHydrationFns) {
;[hydrate, hydrateNode] = createHydrationFns(internals as RendererInternals<
Node,
Element
>)
;[hydrate, hydrateNode] = createHydrationFns(
internals as RendererInternals<Node, Element>
)
}
return {

View File

@@ -44,7 +44,7 @@ import { convertLegacyVModelProps } from './compat/componentVModel'
import { defineLegacyVNodeProperties } from './compat/renderFn'
import { convertLegacyRefInFor } from './compat/ref'
export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
export const Fragment = Symbol(__DEV__ ? 'Fragment' : undefined) as any as {
__isFragment: true
new (): {
$props: VNodeProps
@@ -78,7 +78,7 @@ export type VNodeNormalizedRefAtom = {
export type VNodeNormalizedRef =
| VNodeNormalizedRefAtom
| (VNodeNormalizedRefAtom)[]
| VNodeNormalizedRefAtom[]
type VNodeMountHook = (vnode: VNode) => void
type VNodeUpdateHook = (vnode: VNode, oldVNode: VNode) => void
@@ -381,11 +381,13 @@ const normalizeKey = ({ key }: VNodeProps): VNode['key'] =>
key != null ? key : null
const normalizeRef = ({ ref }: VNodeProps): VNodeNormalizedRefAtom | null => {
return (ref != null
? isString(ref) || isRef(ref) || isFunction(ref)
? { i: currentRenderingInstance, r: ref }
: ref
: null) as any
return (
ref != null
? isString(ref) || isRef(ref) || isFunction(ref)
? { i: currentRenderingInstance, r: ref }
: ref
: null
) as any
}
function createBaseVNode(
@@ -475,9 +477,9 @@ function createBaseVNode(
export { createBaseVNode as createElementVNode }
export const createVNode = (__DEV__
? createVNodeWithArgsTransform
: _createVNode) as typeof _createVNode
export const createVNode = (
__DEV__ ? createVNodeWithArgsTransform : _createVNode
) as typeof _createVNode
function _createVNode(
type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
@@ -537,14 +539,14 @@ function _createVNode(
const shapeFlag = isString(type)
? ShapeFlags.ELEMENT
: __FEATURE_SUSPENSE__ && isSuspense(type)
? ShapeFlags.SUSPENSE
: isTeleport(type)
? ShapeFlags.TELEPORT
: isObject(type)
? ShapeFlags.STATEFUL_COMPONENT
: isFunction(type)
? ShapeFlags.FUNCTIONAL_COMPONENT
: 0
? ShapeFlags.SUSPENSE
: isTeleport(type)
? ShapeFlags.TELEPORT
: isObject(type)
? ShapeFlags.STATEFUL_COMPONENT
: isFunction(type)
? ShapeFlags.FUNCTIONAL_COMPONENT
: 0
if (__DEV__ && shapeFlag & ShapeFlags.STATEFUL_COMPONENT && isProxy(type)) {
type = toRaw(type)
@@ -579,7 +581,7 @@ export function guardReactiveProps(props: (Data & VNodeProps) | null) {
export function cloneVNode<T, U>(
vnode: VNode<T, U>,
extraProps?: Data & VNodeProps | null,
extraProps?: (Data & VNodeProps) | null,
mergeRef = false
): VNode<T, U> {
// This is intentionally NOT using spread or extend to avoid the runtime