Skip to content

Commit d045055

Browse files
fix(core): typing of key in VNodeProps (#4242)
close #4240
1 parent 9bee5cc commit d045055

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface KeepAliveProps {
4646
max?: number | string
4747
}
4848

49-
type CacheKey = string | number | ConcreteComponent
49+
type CacheKey = string | number | symbol | ConcreteComponent
5050
type Cache = Map<CacheKey, VNode>
5151
type Keys = Set<CacheKey>
5252

packages/runtime-core/src/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ function baseCreateRenderer(
18731873
const s2 = i // next starting index
18741874

18751875
// 5.1 build key:index map for newChildren
1876-
const keyToNewIndexMap: Map<string | number, number> = new Map()
1876+
const keyToNewIndexMap: Map<string | number | symbol, number> = new Map()
18771877
for (i = s2; i <= e2; i++) {
18781878
const nextChild = (c2[i] = optimized
18791879
? cloneIfMounted(c2[i] as VNode)

packages/runtime-core/src/vnode.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export type VNodeHook =
9090

9191
// https://github.com/microsoft/TypeScript/issues/33099
9292
export type VNodeProps = {
93-
key?: string | number
93+
key?: string | number | symbol
9494
ref?: VNodeRef
9595

9696
// vnode hooks
@@ -138,7 +138,7 @@ export interface VNode<
138138

139139
type: VNodeTypes
140140
props: (VNodeProps & ExtraProps) | null
141-
key: string | number | null
141+
key: string | number | symbol | null
142142
ref: VNodeNormalizedRef | null
143143
/**
144144
* SFC only. This is assigned on vnode creation using currentScopeId

0 commit comments

Comments
 (0)