From: Evan You Date: Mon, 23 Sep 2024 00:38:24 +0000 (+0800) Subject: fix(runtime-core): make useId() always return a string X-Git-Tag: v3.5.9~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a177092754642af2f98c33a4feffe8f198c3c950;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): make useId() always return a string --- diff --git a/packages/runtime-core/src/helpers/useId.ts b/packages/runtime-core/src/helpers/useId.ts index f7a2b5fc33..4b51e0dda7 100644 --- a/packages/runtime-core/src/helpers/useId.ts +++ b/packages/runtime-core/src/helpers/useId.ts @@ -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 '' } /**