]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): make useId() always return a string
authorEvan You <evan@vuejs.org>
Mon, 23 Sep 2024 00:38:24 +0000 (08:38 +0800)
committerEvan You <evan@vuejs.org>
Mon, 23 Sep 2024 00:38:38 +0000 (08:38 +0800)
packages/runtime-core/src/helpers/useId.ts

index f7a2b5fc330363a182c2357d471b2e1054bc75b1..4b51e0dda7f3580c9dddda226134a5a7a9df0c8a 100644 (file)
@@ -4,7 +4,7 @@ import {
 } from '../component'
 import { warn } from '../warning'
 
-export function useId(): string | undefined {
+export function useId(): string {
   const i = getCurrentInstance()
   if (i) {
     return (i.appContext.config.idPrefix || 'v') + '-' + i.ids[0] + i.ids[1]++
@@ -14,6 +14,7 @@ export function useId(): string | undefined {
         `instance to be associated with.`,
     )
   }
+  return ''
 }
 
 /**