File tree 3 files changed +7
-4
lines changed
packages/runtime-core/src
packages-private/dts-test
3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 4
4
type MaybeRefOrGetter ,
5
5
type Ref ,
6
6
type ShallowRef ,
7
+ type TemplateRef ,
7
8
type ToRefs ,
8
9
type WritableComputedRef ,
9
10
computed ,
@@ -535,7 +536,7 @@ expectType<string>(toValue(unref2))
535
536
536
537
// useTemplateRef
537
538
const tRef = useTemplateRef ( 'foo' )
538
- expectType < Readonly < ShallowRef < unknown > > > ( tRef )
539
+ expectType < TemplateRef > ( tRef )
539
540
540
541
const 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'
5
5
6
6
export const knownTemplateRefs : WeakSet < ShallowRef > = new WeakSet ( )
7
7
8
+ export type TemplateRef < T = unknown > = Readonly < ShallowRef < T | null > >
9
+
8
10
export function useTemplateRef < T = unknown , Keys extends string = string > (
9
11
key : Keys ,
10
- ) : Readonly < ShallowRef < T | null > > {
12
+ ) : TemplateRef < T > {
11
13
const i = getCurrentInstance ( )
12
14
const r = shallowRef ( null )
13
15
if ( i ) {
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export { defineComponent } from './apiDefineComponent'
64
64
export { defineAsyncComponent } from './apiAsyncComponent'
65
65
export { useAttrs , useSlots } from './apiSetupHelpers'
66
66
export { useModel } from './helpers/useModel'
67
- export { useTemplateRef } from './helpers/useTemplateRef'
67
+ export { useTemplateRef , type TemplateRef } from './helpers/useTemplateRef'
68
68
export { useId } from './helpers/useId'
69
69
export {
70
70
hydrateOnIdle ,
You can’t perform that action at this time.
0 commit comments