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

@@ -123,15 +123,16 @@ describe('SFC <script setup> helpers', () => {
beforeInstance = getCurrentInstance()
const msg = (([__temp, __restore] = withAsyncContext(
() =>
new Promise(r => {
resolve = r
})
)),
(__temp = await __temp),
__restore(),
__temp)
const msg =
(([__temp, __restore] = withAsyncContext(
() =>
new Promise(r => {
resolve = r
})
)),
(__temp = await __temp),
__restore(),
__temp)
// register the lifecycle after an await statement
onMounted(spy)
@@ -141,7 +142,10 @@ describe('SFC <script setup> helpers', () => {
})
const root = nodeOps.createElement('div')
render(h(() => h(Suspense, () => h(Comp))), root)
render(
h(() => h(Suspense, () => h(Comp))),
root
)
expect(spy).not.toHaveBeenCalled()
resolve!('hello')
@@ -186,7 +190,10 @@ describe('SFC <script setup> helpers', () => {
})
const root = nodeOps.createElement('div')
render(h(() => h(Suspense, () => h(Comp))), root)
render(
h(() => h(Suspense, () => h(Comp))),
root
)
expect(spy).not.toHaveBeenCalled()
reject!()
@@ -242,7 +249,10 @@ describe('SFC <script setup> helpers', () => {
})
const root = nodeOps.createElement('div')
render(h(() => h(Suspense, () => h(Comp))), root)
render(
h(() => h(Suspense, () => h(Comp))),
root
)
await ready
expect(inBandInstance).toBe(beforeInstance)

View File

@@ -115,8 +115,8 @@ describe('api: template refs', () => {
const fn = jest.fn()
const toggle = ref(true)
const Comp = defineComponent(() => () =>
toggle.value ? h('div', { ref: fn }) : null
const Comp = defineComponent(
() => () => toggle.value ? h('div', { ref: fn }) : null
)
render(h(Comp), root)
expect(fn.mock.calls[0][0]).toBe(root.children[0])

View File

@@ -168,7 +168,10 @@ describe('api: watch', () => {
state.count++
count.value++
await nextTick()
expect(dummy).toMatchObject([[2, 2, 3], [1, 1, 2]])
expect(dummy).toMatchObject([
[2, 2, 3],
[1, 1, 2]
])
})
it('watching multiple sources: readonly array', async () => {
@@ -188,7 +191,10 @@ describe('api: watch', () => {
state.count++
status.value = true
await nextTick()
expect(dummy).toMatchObject([[2, true], [1, false]])
expect(dummy).toMatchObject([
[2, true],
[1, false]
])
})
it('watching multiple sources: reactive object (with automatic deep: true)', async () => {
@@ -568,7 +574,10 @@ describe('api: watch', () => {
count: ref(0)
},
array: [1, 2, 3],
map: new Map([['a', 1], ['b', 2]]),
map: new Map([
['a', 1],
['b', 2]
]),
set: new Set([1, 2, 3])
})
@@ -868,7 +877,10 @@ describe('api: watch', () => {
mounted() {
// this call runs while Comp is currentInstance, but
// the effect for this `$watch` should nontheless be registered with Child
this.comp!.$watch(() => this.show, () => void 0)
this.comp!.$watch(
() => this.show,
() => void 0
)
}
})
@@ -895,7 +907,7 @@ describe('api: watch', () => {
render() {},
created(this: any) {
instance = this
this.$watch(source, function() {})
this.$watch(source, function () {})
}
})

View File

@@ -97,7 +97,7 @@ describe('component: proxy', () => {
expect(() => (instanceProxy.$data = {})).toThrow(TypeError)
expect(`Attempting to mutate public property "$data"`).toHaveBeenWarned()
const nextTickThis = await instanceProxy.$nextTick(function(this: any) {
const nextTickThis = await instanceProxy.$nextTick(function (this: any) {
return this
})
expect(nextTickThis).toBe(instanceProxy)

View File

@@ -258,9 +258,8 @@ describe('BaseTransition', () => {
) {
const toggle = ref(true)
const { props, cbs } = mockProps({ mode })
const root = mount(
props,
() => (toggle.value ? trueBranch() : falseBranch())
const root = mount(props, () =>
toggle.value ? trueBranch() : falseBranch()
)
// without appear: true, enter hooks should not be called on mount
@@ -348,9 +347,8 @@ describe('BaseTransition', () => {
}: ToggleOptions) {
const toggle = ref(false)
const { props, cbs } = mockProps()
const root = mount(
props,
() => (toggle.value ? trueBranch() : falseBranch())
const root = mount(props, () =>
toggle.value ? trueBranch() : falseBranch()
)
// start enter

View File

@@ -841,10 +841,8 @@ describe('KeepAlive', () => {
const instanceRef = ref<any>(null)
const App = {
render: () => {
return h(
KeepAlive,
{ include: 'Foo' },
() => (toggle.value ? h(AsyncComp, { ref: instanceRef }) : null)
return h(KeepAlive, { include: 'Foo' }, () =>
toggle.value ? h(AsyncComp, { ref: instanceRef }) : null
)
}
}

View File

@@ -106,7 +106,10 @@ describe('renderer: teleport', () => {
const root = nodeOps.createElement('div')
const children = ref([h('div', 'teleported')])
render(h(() => h(Teleport, { to: target }, children.value)), root)
render(
h(() => h(Teleport, { to: target }, children.value)),
root
)
expect(serializeInner(target)).toMatchInlineSnapshot(
`"<div>teleported</div>"`
)

View File

@@ -42,7 +42,10 @@ describe('createSlot', () => {
it('should add each slot to the record when given slot is an array', () => {
const dynamicSlot = [
{ name: 'descriptor', fn: slot },
[{ name: 'descriptor2', fn: slot }, { name: 'descriptor3', fn: slot }]
[
{ name: 'descriptor2', fn: slot },
{ name: 'descriptor3', fn: slot }
]
]
const actual = createSlots(record, dynamicSlot)

View File

@@ -38,7 +38,7 @@ describe('renderList', () => {
})
it('should render an item for entry in an iterable', () => {
const iterable = function*() {
const iterable = function* () {
yield 1
yield 2
yield 3

View File

@@ -759,9 +759,11 @@ describe('SSR hydration', () => {
})
expect(
(app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
el: Element
}).el instanceof SVGElement
(
app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
el: Element
}
).el instanceof SVGElement
)
})

View File

@@ -321,21 +321,28 @@ describe('renderer: keyed children', () => {
}
for (let n = 0; n < samples; ++n) {
render(h('span', arr.map(n => spanNumWithOpacity(n, '1'))), root)
render(
h(
'span',
arr.map(n => spanNumWithOpacity(n, '1'))
),
root
)
elm = root.children[0] as TestElement
for (let i = 0; i < elms; ++i) {
expect(serializeInner(elm.children[i] as TestElement)).toBe(
i.toString()
)
opacities[i] = Math.random()
.toFixed(5)
.toString()
opacities[i] = Math.random().toFixed(5).toString()
}
const shufArr = shuffle(arr.slice(0))
render(
h('span', arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))),
h(
'span',
arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))
),
root
)
elm = root.children[0] as TestElement

View File

@@ -217,7 +217,10 @@ describe('renderer: component', () => {
const Child = {
props: ['value'],
setup(props: any, { emit }: SetupContext) {
watch(() => props.value, (val: number) => emit('update', val))
watch(
() => props.value,
(val: number) => emit('update', val)
)
return () => {
return h('div', props.value)

View File

@@ -417,11 +417,12 @@ describe('renderer: optimized mode', () => {
const Comp = defineComponent({
setup(_props, { slots }) {
return () => {
const vnode = (openBlock(),
(block = createBlock('div', null, {
default: withCtx(() => [renderSlot(slots, 'default')]),
_: SlotFlags.FORWARDED
})))
const vnode =
(openBlock(),
(block = createBlock('div', null, {
default: withCtx(() => [renderSlot(slots, 'default')]),
_: SlotFlags.FORWARDED
})))
return vnode
}
@@ -449,8 +450,9 @@ describe('renderer: optimized mode', () => {
expect(block!.dynamicChildren![0].type).toBe(Fragment)
expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(1)
expect(
serialize(block!.dynamicChildren![0].dynamicChildren![0]
.el as TestElement)
serialize(
block!.dynamicChildren![0].dynamicChildren![0].el as TestElement
)
).toBe('<p>0</p>')
foo.value++

View File

@@ -226,7 +226,7 @@ describe('backwards compat with <=3.0.7', () => {
test('should work on slots', () => {
const Child = {
__scopeId: 'child',
render: withChildId(function(this: any) {
render: withChildId(function (this: any) {
return h('div', renderSlot(this.$slots, 'default'))
})
}

View File

@@ -411,9 +411,9 @@ describe('vnode', () => {
})
test('handlers', () => {
let clickHandler1 = function() {}
let clickHandler2 = function() {}
let focusHandler2 = function() {}
let clickHandler1 = function () {}
let clickHandler2 = function () {}
let focusHandler2 = function () {}
let props1: Data = { onClick: clickHandler1 }
let props2: Data = { onClick: clickHandler2, onFocus: focusHandler2 }
@@ -439,37 +439,41 @@ describe('vnode', () => {
test('with patchFlags', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
]))
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
test('should not track vnodes with only HYDRATE_EVENTS flag', () => {
const hoist = createVNode('div')
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
createVNode('div', null, 'text', PatchFlags.HYDRATE_EVENTS)
]))
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
createVNode('div', null, 'text', PatchFlags.HYDRATE_EVENTS)
]))
expect(vnode.dynamicChildren).toStrictEqual([])
})
test('many times call openBlock', () => {
const hoist = createVNode('div')
let vnode1, vnode2, vnode3
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
(vnode2 = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
])))
]))
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
(vnode2 =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
])))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
expect(vnode2.dynamicChildren).toStrictEqual([vnode3])
})
@@ -477,33 +481,36 @@ describe('vnode', () => {
test('with stateful component', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode({}, null, 'text'))
]))
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode({}, null, 'text'))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
test('with functional component', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
]))
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
test('with suspense', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
]))
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
@@ -516,32 +523,35 @@ describe('vnode', () => {
test('element block should track normalized slot children', () => {
const hoist = createVNode('div')
let vnode1: any
const vnode = (openBlock(),
createBlock('div', null, {
default: () => {
return [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
]
}
}))
const vnode =
(openBlock(),
createBlock('div', null, {
default: () => {
return [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
]
}
}))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
test('openBlock w/ disableTracking: true', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
// a v-for fragment block generated by the compiler
// disables tracking because it always diffs its
// children.
(vnode1 = (openBlock(true),
createBlock(Fragment, null, [
hoist,
/*vnode2*/ createVNode(() => {}, null, 'text')
])))
]))
const vnode =
(openBlock(),
createBlock('div', null, [
// a v-for fragment block generated by the compiler
// disables tracking because it always diffs its
// children.
(vnode1 =
(openBlock(true),
createBlock(Fragment, null, [
hoist,
/*vnode2*/ createVNode(() => {}, null, 'text')
])))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
expect(vnode1.dynamicChildren).toStrictEqual([])
})
@@ -549,27 +559,30 @@ describe('vnode', () => {
test('openBlock without disableTracking: true', () => {
const hoist = createVNode('div')
let vnode1, vnode2
const vnode = (openBlock(),
createBlock('div', null, [
(vnode1 = (openBlock(),
createBlock(Fragment, null, [
hoist,
(vnode2 = createVNode(() => {}, null, 'text'))
])))
]))
const vnode =
(openBlock(),
createBlock('div', null, [
(vnode1 =
(openBlock(),
createBlock(Fragment, null, [
hoist,
(vnode2 = createVNode(() => {}, null, 'text'))
])))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
expect(vnode1.dynamicChildren).toStrictEqual([vnode2])
})
test('should not track openBlock() when tracking is disabled', () => {
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
setBlockTracking(-1),
(vnode1 = (openBlock(), createBlock('div'))),
setBlockTracking(1),
vnode1
]))
const vnode =
(openBlock(),
createBlock('div', null, [
setBlockTracking(-1),
(vnode1 = (openBlock(), createBlock('div'))),
setBlockTracking(1),
vnode1
]))
expect(vnode.dynamicChildren).toStrictEqual([])
})
})

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