File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
packages-private/dts-test
packages/runtime-core/src Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 44 type MaybeRefOrGetter ,
55 type Ref ,
66 type ShallowRef ,
7+ type TemplateRef ,
78 type ToRefs ,
89 type WritableComputedRef ,
910 computed ,
@@ -535,7 +536,7 @@ expectType<string>(toValue(unref2))
535536
536537// useTemplateRef
537538const tRef = useTemplateRef ( 'foo' )
538- expectType < Readonly < ShallowRef < unknown > > > ( tRef )
539+ expectType < TemplateRef > ( tRef )
539540
540541const tRef2 = useTemplateRef < HTMLElement > ( 'bar' )
541- expectType < Readonly < ShallowRef < HTMLElement | null > > > ( tRef2 )
542+ expectType < TemplateRef < HTMLElement > > ( tRef2 )
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { EMPTY_OBJ } from '@vue/shared'
55
66export const knownTemplateRefs : WeakSet < ShallowRef > = new WeakSet ( )
77
8+ export type TemplateRef < T = unknown > = Readonly < ShallowRef < T | null > >
9+
810export function useTemplateRef < T = unknown , Keys extends string = string > (
911 key : Keys ,
10- ) : Readonly < ShallowRef < T | null > > {
12+ ) : TemplateRef < T > {
1113 const i = getCurrentInstance ( )
1214 const r = shallowRef ( null )
1315 if ( i ) {
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export { defineComponent } from './apiDefineComponent'
6464export { defineAsyncComponent } from './apiAsyncComponent'
6565export { useAttrs , useSlots } from './apiSetupHelpers'
6666export { useModel } from './helpers/useModel'
67- export { useTemplateRef } from './helpers/useTemplateRef'
67+ export { useTemplateRef , type TemplateRef } from './helpers/useTemplateRef'
6868export { useId } from './helpers/useId'
6969export {
7070 hydrateOnIdle ,
You can’t perform that action at this time.
0 commit comments