fix(nuxt): remove key from useId type signature (#25614)

This commit is contained in:
Daniel Roe 2024-02-04 22:11:53 +00:00 committed by GitHub
parent 3e5560ed42
commit e8d1219886
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -7,6 +7,7 @@ const ATTR_KEY = 'data-n-ids'
/**
* Generate an SSR-friendly unique identifier that can be passed to accessibility attributes.
*/
export function useId (): string
export function useId (key?: string): string {
if (typeof key !== 'string') {
throw new TypeError('[nuxt] [useId] key must be a string.')

View File

@ -362,6 +362,11 @@ describe('composables', () => {
expectTypeOf(useFetch('/test', { default: () => 500 }).data).toEqualTypeOf<Ref<unknown>>()
})
it('prevents passing string to `useId`', () => {
// @ts-expect-error providing a key is not allowed
useId('test')
})
it('enforces readonly cookies', () => {
// @ts-expect-error readonly cookie
useCookie('test', { readonly: true }).value = 'thing'