chore: run updated prettier
This commit is contained in:
@@ -422,7 +422,7 @@ describe('reactivity/collections', () => {
|
||||
const proxy = reactive(raw)
|
||||
const thisArg = {}
|
||||
let count = 0
|
||||
proxy.forEach(function(this: {}, value, _, set) {
|
||||
proxy.forEach(function (this: {}, value, _, set) {
|
||||
++count
|
||||
expect(this).toBe(thisArg)
|
||||
expect(value).toBe('value')
|
||||
|
||||
@@ -178,7 +178,10 @@ describe('reactivity/readonly', () => {
|
||||
test('should make nested values readonly', () => {
|
||||
const key1 = {}
|
||||
const key2 = {}
|
||||
const original = new Collection([[key1, {}], [key2, {}]])
|
||||
const original = new Collection([
|
||||
[key1, {}],
|
||||
[key2, {}]
|
||||
])
|
||||
const wrapped = readonly(original)
|
||||
expect(wrapped).not.toBe(original)
|
||||
expect(isProxy(wrapped)).toBe(true)
|
||||
@@ -228,7 +231,10 @@ describe('reactivity/readonly', () => {
|
||||
test('should retrieve readonly values on iteration', () => {
|
||||
const key1 = {}
|
||||
const key2 = {}
|
||||
const original = new Map([[key1, {}], [key2, {}]])
|
||||
const original = new Map([
|
||||
[key1, {}],
|
||||
[key2, {}]
|
||||
])
|
||||
const wrapped: any = readonly(original)
|
||||
expect(wrapped.size).toBe(2)
|
||||
for (const [key, value] of wrapped) {
|
||||
@@ -246,7 +252,12 @@ describe('reactivity/readonly', () => {
|
||||
test('should retrieve reactive + readonly values on iteration', () => {
|
||||
const key1 = {}
|
||||
const key2 = {}
|
||||
const original = reactive(new Map([[key1, {}], [key2, {}]]))
|
||||
const original = reactive(
|
||||
new Map([
|
||||
[key1, {}],
|
||||
[key2, {}]
|
||||
])
|
||||
)
|
||||
const wrapped: any = readonly(original)
|
||||
expect(wrapped.size).toBe(2)
|
||||
for (const [key, value] of wrapped) {
|
||||
|
||||
@@ -49,7 +49,7 @@ function createArrayInstrumentations() {
|
||||
// instrument identity-sensitive Array methods to account for possible reactive
|
||||
// values
|
||||
;(['includes', 'indexOf', 'lastIndexOf'] as const).forEach(key => {
|
||||
instrumentations[key] = function(this: unknown[], ...args: unknown[]) {
|
||||
instrumentations[key] = function (this: unknown[], ...args: unknown[]) {
|
||||
const arr = toRaw(this) as any
|
||||
for (let i = 0, l = this.length; i < l; i++) {
|
||||
track(arr, TrackOpTypes.GET, i + '')
|
||||
@@ -67,7 +67,7 @@ function createArrayInstrumentations() {
|
||||
// instrument length-altering mutation methods to avoid length being tracked
|
||||
// which leads to infinite loops in some cases (#2137)
|
||||
;(['push', 'pop', 'shift', 'unshift', 'splice'] as const).forEach(key => {
|
||||
instrumentations[key] = function(this: unknown[], ...args: unknown[]) {
|
||||
instrumentations[key] = function (this: unknown[], ...args: unknown[]) {
|
||||
pauseTracking()
|
||||
const res = (toRaw(this) as any)[key].apply(this, args)
|
||||
resetTracking()
|
||||
@@ -91,8 +91,8 @@ function createGetter(isReadonly = false, shallow = false) {
|
||||
? shallowReadonlyMap
|
||||
: readonlyMap
|
||||
: shallow
|
||||
? shallowReactiveMap
|
||||
: reactiveMap
|
||||
? shallowReactiveMap
|
||||
: reactiveMap
|
||||
).get(target)
|
||||
) {
|
||||
return target
|
||||
|
||||
@@ -184,7 +184,7 @@ function createIterableMethod(
|
||||
isReadonly: boolean,
|
||||
isShallow: boolean
|
||||
) {
|
||||
return function(
|
||||
return function (
|
||||
this: IterableCollections,
|
||||
...args: unknown[]
|
||||
): Iterable & Iterator {
|
||||
@@ -224,7 +224,7 @@ function createIterableMethod(
|
||||
}
|
||||
|
||||
function createReadonlyMethod(type: TriggerOpTypes): Function {
|
||||
return function(this: CollectionTypes, ...args: unknown[]) {
|
||||
return function (this: CollectionTypes, ...args: unknown[]) {
|
||||
if (__DEV__) {
|
||||
const key = args[0] ? `on key "${args[0]}" ` : ``
|
||||
console.warn(
|
||||
@@ -242,7 +242,7 @@ function createInstrumentations() {
|
||||
return get(this, key)
|
||||
},
|
||||
get size() {
|
||||
return size((this as unknown) as IterableCollections)
|
||||
return size(this as unknown as IterableCollections)
|
||||
},
|
||||
has,
|
||||
add,
|
||||
@@ -257,7 +257,7 @@ function createInstrumentations() {
|
||||
return get(this, key, false, true)
|
||||
},
|
||||
get size() {
|
||||
return size((this as unknown) as IterableCollections)
|
||||
return size(this as unknown as IterableCollections)
|
||||
},
|
||||
has,
|
||||
add,
|
||||
@@ -272,7 +272,7 @@ function createInstrumentations() {
|
||||
return get(this, key, true)
|
||||
},
|
||||
get size() {
|
||||
return size((this as unknown) as IterableCollections, true)
|
||||
return size(this as unknown as IterableCollections, true)
|
||||
},
|
||||
has(this: MapTypes, key: unknown) {
|
||||
return has.call(this, key, true)
|
||||
@@ -289,7 +289,7 @@ function createInstrumentations() {
|
||||
return get(this, key, true, true)
|
||||
},
|
||||
get size() {
|
||||
return size((this as unknown) as IterableCollections, true)
|
||||
return size(this as unknown as IterableCollections, true)
|
||||
},
|
||||
has(this: MapTypes, key: unknown) {
|
||||
return has.call(this, key, true)
|
||||
@@ -346,8 +346,8 @@ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) {
|
||||
? shallowReadonlyInstrumentations
|
||||
: shallowInstrumentations
|
||||
: isReadonly
|
||||
? readonlyInstrumentations
|
||||
: mutableInstrumentations
|
||||
? readonlyInstrumentations
|
||||
: mutableInstrumentations
|
||||
|
||||
return (
|
||||
target: CollectionTypes,
|
||||
@@ -384,11 +384,10 @@ export const readonlyCollectionHandlers: ProxyHandler<CollectionTypes> = {
|
||||
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
||||
}
|
||||
|
||||
export const shallowReadonlyCollectionHandlers: ProxyHandler<
|
||||
CollectionTypes
|
||||
> = {
|
||||
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
||||
}
|
||||
export const shallowReadonlyCollectionHandlers: ProxyHandler<CollectionTypes> =
|
||||
{
|
||||
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
||||
}
|
||||
|
||||
function checkIdentityKeys(
|
||||
target: CollectionTypes,
|
||||
|
||||
@@ -37,7 +37,7 @@ class ComputedRefImpl<T> {
|
||||
private _dirty = true
|
||||
public readonly effect: ReactiveEffect<T>
|
||||
|
||||
public readonly __v_isRef = true;
|
||||
public readonly __v_isRef = true
|
||||
public readonly [ReactiveFlags.IS_READONLY]: boolean
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -119,22 +119,22 @@ type Builtin = Primitive | Function | Date | Error | RegExp
|
||||
export type DeepReadonly<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Map<infer K, infer V>
|
||||
? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
||||
: T extends ReadonlyMap<infer K, infer V>
|
||||
? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
||||
: T extends WeakMap<infer K, infer V>
|
||||
? WeakMap<DeepReadonly<K>, DeepReadonly<V>>
|
||||
: T extends Set<infer U>
|
||||
? ReadonlySet<DeepReadonly<U>>
|
||||
: T extends ReadonlySet<infer U>
|
||||
? ReadonlySet<DeepReadonly<U>>
|
||||
: T extends WeakSet<infer U>
|
||||
? WeakSet<DeepReadonly<U>>
|
||||
: T extends Promise<infer U>
|
||||
? Promise<DeepReadonly<U>>
|
||||
: T extends {}
|
||||
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
||||
: Readonly<T>
|
||||
? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
||||
: T extends ReadonlyMap<infer K, infer V>
|
||||
? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
||||
: T extends WeakMap<infer K, infer V>
|
||||
? WeakMap<DeepReadonly<K>, DeepReadonly<V>>
|
||||
: T extends Set<infer U>
|
||||
? ReadonlySet<DeepReadonly<U>>
|
||||
: T extends ReadonlySet<infer U>
|
||||
? ReadonlySet<DeepReadonly<U>>
|
||||
: T extends WeakSet<infer U>
|
||||
? WeakSet<DeepReadonly<U>>
|
||||
: T extends Promise<infer U>
|
||||
? Promise<DeepReadonly<U>>
|
||||
: T extends {}
|
||||
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
||||
: Readonly<T>
|
||||
|
||||
/**
|
||||
* Creates a readonly copy of the original object. Note the returned copy is not
|
||||
|
||||
@@ -259,8 +259,10 @@ export type ShallowUnwrapRef<T> = {
|
||||
[K in keyof T]: T[K] extends Ref<infer V>
|
||||
? V
|
||||
: T[K] extends Ref<infer V> | undefined // if `V` is `unknown` that means it does not extend `Ref` and is undefined
|
||||
? unknown extends V ? undefined : V | undefined
|
||||
: T[K]
|
||||
? unknown extends V
|
||||
? undefined
|
||||
: V | undefined
|
||||
: T[K]
|
||||
}
|
||||
|
||||
export type UnwrapRef<T> = T extends Ref<infer V>
|
||||
@@ -275,8 +277,10 @@ type UnwrapRefSimple<T> = T extends
|
||||
| RefUnwrapBailTypes[keyof RefUnwrapBailTypes]
|
||||
? T
|
||||
: T extends Array<any>
|
||||
? { [K in keyof T]: UnwrapRefSimple<T[K]> }
|
||||
: T extends object ? UnwrappedObject<T> : T
|
||||
? { [K in keyof T]: UnwrapRefSimple<T[K]> }
|
||||
: T extends object
|
||||
? UnwrappedObject<T>
|
||||
: T
|
||||
|
||||
// Extract all known symbols from an object
|
||||
// when unwrapping Object the symbols are not `in keyof`, this should cover all the
|
||||
|
||||
Reference in New Issue
Block a user