Skip to content

types(reactivity): modify the type of Instrumentations #6162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions packages/reactivity/src/collectionHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function createReadonlyMethod(type: TriggerOpTypes): Function {
}

function createInstrumentations() {
const mutableInstrumentations: Record<string, Function> = {
const mutableInstrumentations: Record<string | symbol, Function> = {
get(this: MapTypes, key: unknown) {
return get(this, key)
},
Expand All @@ -243,7 +243,7 @@ function createInstrumentations() {
forEach: createForEach(false, false)
}

const shallowInstrumentations: Record<string, Function> = {
const shallowInstrumentations: Record<string | symbol, Function> = {
get(this: MapTypes, key: unknown) {
return get(this, key, false, true)
},
Expand All @@ -258,7 +258,7 @@ function createInstrumentations() {
forEach: createForEach(false, true)
}

const readonlyInstrumentations: Record<string, Function> = {
const readonlyInstrumentations: Record<string | symbol, Function> = {
get(this: MapTypes, key: unknown) {
return get(this, key, true)
},
Expand All @@ -275,7 +275,7 @@ function createInstrumentations() {
forEach: createForEach(true, false)
}

const shallowReadonlyInstrumentations: Record<string, Function> = {
const shallowReadonlyInstrumentations: Record<string | symbol, Function> = {
get(this: MapTypes, key: unknown) {
return get(this, key, true, true)
},
Expand All @@ -294,22 +294,10 @@ function createInstrumentations() {

const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]
iteratorMethods.forEach(method => {
mutableInstrumentations[method as string] = createIterableMethod(
method,
false,
false
)
readonlyInstrumentations[method as string] = createIterableMethod(
method,
true,
false
)
shallowInstrumentations[method as string] = createIterableMethod(
method,
false,
true
)
shallowReadonlyInstrumentations[method as string] = createIterableMethod(
mutableInstrumentations[method] = createIterableMethod(method, false, false)
readonlyInstrumentations[method] = createIterableMethod(method, true, false)
shallowInstrumentations[method] = createIterableMethod(method, false, true)
shallowReadonlyInstrumentations[method] = createIterableMethod(
method,
true,
true
Expand Down