mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): remove key from useId
type signature (#25614)
This commit is contained in:
parent
3e5560ed42
commit
e8d1219886
@ -7,6 +7,7 @@ const ATTR_KEY = 'data-n-ids'
|
|||||||
/**
|
/**
|
||||||
* Generate an SSR-friendly unique identifier that can be passed to accessibility attributes.
|
* Generate an SSR-friendly unique identifier that can be passed to accessibility attributes.
|
||||||
*/
|
*/
|
||||||
|
export function useId (): string
|
||||||
export function useId (key?: string): string {
|
export function useId (key?: string): string {
|
||||||
if (typeof key !== 'string') {
|
if (typeof key !== 'string') {
|
||||||
throw new TypeError('[nuxt] [useId] key must be a string.')
|
throw new TypeError('[nuxt] [useId] key must be a string.')
|
||||||
|
5
test/fixtures/basic-types/types.ts
vendored
5
test/fixtures/basic-types/types.ts
vendored
@ -362,6 +362,11 @@ describe('composables', () => {
|
|||||||
expectTypeOf(useFetch('/test', { default: () => 500 }).data).toEqualTypeOf<Ref<unknown>>()
|
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', () => {
|
it('enforces readonly cookies', () => {
|
||||||
// @ts-expect-error readonly cookie
|
// @ts-expect-error readonly cookie
|
||||||
useCookie('test', { readonly: true }).value = 'thing'
|
useCookie('test', { readonly: true }).value = 'thing'
|
||||||
|
Loading…
Reference in New Issue
Block a user