diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index cca1b8d96..e9c8cce58 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -195,10 +195,10 @@ const KeepAliveImpl: ComponentOptions = { _unmount(vnode, instance, parentSuspense, true) } - function pruneCache(filter?: (name: string) => boolean) { + function pruneCache(filter: (name: string) => boolean) { cache.forEach((vnode, key) => { const name = getComponentName(vnode.type as ConcreteComponent) - if (name && (!filter || !filter(name))) { + if (name && !filter(name)) { pruneCacheEntry(key) } })