]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(core): typing of key in VNodeProps (#4242)
authorAlexandraCaragata <33446699+AlexandraCaragata@users.noreply.github.com>
Fri, 6 Aug 2021 15:11:26 +0000 (17:11 +0200)
committerGitHub <noreply@github.com>
Fri, 6 Aug 2021 15:11:26 +0000 (11:11 -0400)
close #4240

packages/runtime-core/src/components/KeepAlive.ts
packages/runtime-core/src/renderer.ts
packages/runtime-core/src/vnode.ts

index 9bccf40f576749f20c7088e1e73efe5c09f5eb83..30ad4400da6b17ab261b85b99eb5c80525492773 100644 (file)
@@ -46,7 +46,7 @@ export interface KeepAliveProps {
   max?: number | string
 }
 
-type CacheKey = string | number | ConcreteComponent
+type CacheKey = string | number | symbol | ConcreteComponent
 type Cache = Map<CacheKey, VNode>
 type Keys = Set<CacheKey>
 
index 680f0c696fe4d5e1bfb5aa7eb784428d4501d7c6..62db9cd8cb91d864cecc5b96ef15535aae81e173 100644 (file)
@@ -1873,7 +1873,7 @@ function baseCreateRenderer(
       const s2 = i // next starting index
 
       // 5.1 build key:index map for newChildren
-      const keyToNewIndexMap: Map<string | number, number> = new Map()
+      const keyToNewIndexMap: Map<string | number | symbol, number> = new Map()
       for (i = s2; i <= e2; i++) {
         const nextChild = (c2[i] = optimized
           ? cloneIfMounted(c2[i] as VNode)
index 18db9cf5e258125e07e9aa672c0a05d2104e59cf..26b2ac9e42316a1fa7ef5d2f5b13daffd80bb1b1 100644 (file)
@@ -90,7 +90,7 @@ export type VNodeHook =
 
 // https://github.com/microsoft/TypeScript/issues/33099
 export type VNodeProps = {
-  key?: string | number
+  key?: string | number | symbol
   ref?: VNodeRef
 
   // vnode hooks
@@ -138,7 +138,7 @@ export interface VNode<
 
   type: VNodeTypes
   props: (VNodeProps & ExtraProps) | null
-  key: string | number | null
+  key: string | number | symbol | null
   ref: VNodeNormalizedRef | null
   /**
    * SFC only. This is assigned on vnode creation using currentScopeId