Skip to content

Commit 67812c6

Browse files
authored
refactor(useClipboard)!: use readonly() instead of type assertion Computed (#5081)
1 parent 3f7f761 commit 67812c6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/core/useClipboard/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* this implementation is original ported from https://github.com/logaretm/vue-use-web by Abdelrahman Awad */
22

3-
import type { ComputedRef, MaybeRefOrGetter } from 'vue'
3+
import type { ComputedRef, MaybeRefOrGetter, ShallowRef } from 'vue'
44
import type { ConfigurableNavigator } from '../_configurable'
55
import { useTimeoutFn } from '@vueuse/shared'
6-
import { computed, shallowRef, toValue } from 'vue'
6+
import { computed, readonly, shallowRef, toValue } from 'vue'
77
import { defaultNavigator } from '../_configurable'
88
import { useEventListener } from '../useEventListener'
99
import { usePermission } from '../usePermission'
@@ -39,8 +39,8 @@ export interface UseClipboardOptions<Source> extends ConfigurableNavigator {
3939

4040
export interface UseClipboardReturn<Optional> {
4141
isSupported: ComputedRef<boolean>
42-
text: ComputedRef<string>
43-
copied: ComputedRef<boolean>
42+
text: Readonly<ShallowRef<string>>
43+
copied: Readonly<ShallowRef<boolean>>
4444
copy: Optional extends true ? (text?: string) => Promise<void> : (text: string) => Promise<void>
4545
}
4646

@@ -130,8 +130,8 @@ export function useClipboard(options: UseClipboardOptions<MaybeRefOrGetter<strin
130130

131131
return {
132132
isSupported,
133-
text: text as ComputedRef<string>,
134-
copied: copied as ComputedRef<boolean>,
133+
text: readonly(text),
134+
copied: readonly(copied),
135135
copy,
136136
}
137137
}

0 commit comments

Comments
 (0)