Skip to content

Commit

Permalink
chore: use PropertyKey type (vuejs#11056)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasvn authored Jun 6, 2024
1 parent a88295d commit 32262a9
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/reactivity/src/reactiveEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function trigger(
resetScheduling()
}

export function getDepFromReactive(object: any, key: string | number | symbol) {
export function getDepFromReactive(object: any, key: PropertyKey) {
const depsMap = targetMap.get(object)
return depsMap && depsMap.get(key)
}
14 changes: 7 additions & 7 deletions packages/runtime-core/src/apiSetupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function defineSlots<
return null as any
}

export type ModelRef<T, M extends string | number | symbol = string> = Ref<T> &
export type ModelRef<T, M extends PropertyKey = string> = Ref<T> &
[ModelRef<T, M>, Record<M, true | undefined>]

export type DefineModelOptions<T = any> = {
Expand Down Expand Up @@ -256,24 +256,24 @@ export type DefineModelOptions<T = any> = {
* const count = defineModel<number>('count', { default: 0 })
* ```
*/
export function defineModel<T, M extends string | number | symbol = string>(
export function defineModel<T, M extends PropertyKey = string>(
options: { required: true } & PropOptions<T> & DefineModelOptions<T>,
): ModelRef<T, M>
export function defineModel<T, M extends string | number | symbol = string>(
export function defineModel<T, M extends PropertyKey = string>(
options: { default: any } & PropOptions<T> & DefineModelOptions<T>,
): ModelRef<T, M>
export function defineModel<T, M extends string | number | symbol = string>(
export function defineModel<T, M extends PropertyKey = string>(
options?: PropOptions<T> & DefineModelOptions<T>,
): ModelRef<T | undefined, M>
export function defineModel<T, M extends string | number | symbol = string>(
export function defineModel<T, M extends PropertyKey = string>(
name: string,
options: { required: true } & PropOptions<T> & DefineModelOptions<T>,
): ModelRef<T, M>
export function defineModel<T, M extends string | number | symbol = string>(
export function defineModel<T, M extends PropertyKey = string>(
name: string,
options: { default: any } & PropOptions<T> & DefineModelOptions<T>,
): ModelRef<T, M>
export function defineModel<T, M extends string | number | symbol = string>(
export function defineModel<T, M extends PropertyKey = string>(
name: string,
options?: PropOptions<T> & DefineModelOptions<T>,
): ModelRef<T | undefined, M>
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/compat/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
/**
* @deprecated Vue 3 no longer needs set() for adding new properties.
*/
set(target: any, key: string | number | symbol, value: any): void
set(target: any, key: PropertyKey, value: any): void
/**
* @deprecated Vue 3 no longer needs delete() for property deletions.
*/
delete(target: any, key: string | number | symbol): void
delete(target: any, key: PropertyKey): void
/**
* @deprecated use `reactive` instead.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/KeepAlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface KeepAliveProps {
max?: number | string
}

type CacheKey = string | number | symbol | ConcreteComponent
type CacheKey = PropertyKey | ConcreteComponent
type Cache = Map<CacheKey, VNode>
type Keys = Set<CacheKey>

Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/helpers/useModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { NormalizedProps } from '../componentProps'
import { watchSyncEffect } from '../apiWatch'

export function useModel<
M extends string | number | symbol,
M extends PropertyKey,
T extends Record<string, any>,
K extends keyof T,
>(props: T, name: K, options?: DefineModelOptions<T[K]>): ModelRef<T[K], M>
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ function baseCreateRenderer(
const s2 = i // next starting index

// 5.1 build key:index map for newChildren
const keyToNewIndexMap: Map<string | number | symbol, number> = new Map()
const keyToNewIndexMap: Map<PropertyKey, number> = new Map()
for (i = s2; i <= e2; i++) {
const nextChild = (c2[i] = optimized
? cloneIfMounted(c2[i] as VNode)
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export type VNodeHook =

// https://github.com/microsoft/TypeScript/issues/33099
export type VNodeProps = {
key?: string | number | symbol
key?: PropertyKey
ref?: VNodeRef
ref_for?: boolean
ref_key?: string
Expand Down Expand Up @@ -162,7 +162,7 @@ export interface VNode<

type: VNodeTypes
props: (VNodeProps & ExtraProps) | null
key: string | number | symbol | null
key: PropertyKey | null
ref: VNodeNormalizedRef | null
/**
* SFC only. This is assigned on vnode creation using currentScopeId
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ type EventHandlers<E> = {
import type { VNodeRef } from '@vue/runtime-core'

export type ReservedProps = {
key?: string | number | symbol
key?: PropertyKey
ref?: VNodeRef
ref_for?: boolean
ref_key?: string
Expand Down

0 comments on commit 32262a9

Please sign in to comment.