From a086e8b6619c2fc3ec3a25bfbed7b5dce2f46787 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 20 Feb 2024 09:21:52 +0100 Subject: [PATCH] fix: stricter types --- packages/.test/mount.ts | 2 +- packages/core/createReusableTemplate/index.ts | 2 +- packages/core/createTemplatePromise/index.ts | 2 +- packages/core/ssr-handlers.ts | 12 +++--- packages/core/useBreakpoints/index.ts | 16 ++++---- packages/core/useEventListener/index.ts | 4 +- packages/core/useFetch/index.ts | 24 +++++------ packages/core/useMemoize/index.md | 10 ++--- packages/core/useMemoize/index.ts | 18 ++++----- packages/core/usePointerLock/index.ts | 25 ++++++------ packages/core/useRefHistory/index.ts | 8 ++-- packages/core/useScreenOrientation/index.ts | 6 +-- packages/core/useSpeechRecognition/types.ts | 40 +++++++++---------- packages/core/useStorage/index.ts | 10 ++--- packages/core/useTemplateRefsList/index.ts | 2 +- packages/electron/useIpcRenderer/index.ts | 20 +++++----- packages/integrations/useIDBKeyval/index.ts | 2 +- packages/integrations/useSortable/index.ts | 10 +++-- packages/shared/computedWithControl/index.ts | 2 +- packages/shared/until/index.ts | 27 ++++++------- packages/shared/utils/types.ts | 2 +- 21 files changed, 122 insertions(+), 122 deletions(-) diff --git a/packages/.test/mount.ts b/packages/.test/mount.ts index 86ab7f90412..0dd280a13bf 100644 --- a/packages/.test/mount.ts +++ b/packages/.test/mount.ts @@ -2,7 +2,7 @@ import type { InjectionKey, Ref } from 'vue-demi' import { createApp, defineComponent, h, provide, ref } from 'vue-demi' type InstanceType = V extends { new (...arg: any[]): infer X } ? X : never -type VM = InstanceType & { unmount(): void } +type VM = InstanceType & { unmount: () => void } export function mount(Comp: V) { const el = document.createElement('div') diff --git a/packages/core/createReusableTemplate/index.ts b/packages/core/createReusableTemplate/index.ts index e78ede8cac1..ba1ccb1c6e4 100644 --- a/packages/core/createReusableTemplate/index.ts +++ b/packages/core/createReusableTemplate/index.ts @@ -6,7 +6,7 @@ export type DefineTemplateComponent< Bindings extends object, Slots extends Record, > = DefineComponent<{}> & { - new(): { $slots: { default(_: Bindings & { $slots: Slots }): any } } + new(): { $slots: { default: (_: Bindings & { $slots: Slots }) => any } } } export type ReuseTemplateComponent< diff --git a/packages/core/createTemplatePromise/index.ts b/packages/core/createTemplatePromise/index.ts index 94ca26c05c0..d6ca04ec2cd 100644 --- a/packages/core/createTemplatePromise/index.ts +++ b/packages/core/createTemplatePromise/index.ts @@ -50,7 +50,7 @@ export interface TemplatePromiseOptions { export type TemplatePromise = DefineComponent<{}> & { new(): { $slots: { - default(_: TemplatePromiseProps): any + default: (_: TemplatePromiseProps) => any } } } & { diff --git a/packages/core/ssr-handlers.ts b/packages/core/ssr-handlers.ts index 8f8641794d1..31cd4b139d0 100644 --- a/packages/core/ssr-handlers.ts +++ b/packages/core/ssr-handlers.ts @@ -3,15 +3,15 @@ import type { Awaitable } from '@vueuse/shared' import type { MaybeElementRef } from './unrefElement' export interface StorageLikeAsync { - getItem(key: string): Awaitable - setItem(key: string, value: string): Awaitable - removeItem(key: string): Awaitable + getItem: (key: string) => Awaitable + setItem: (key: string, value: string) => Awaitable + removeItem: (key: string) => Awaitable } export interface StorageLike { - getItem(key: string): string | null - setItem(key: string, value: string): void - removeItem(key: string): void + getItem: (key: string) => string | null + setItem: (key: string, value: string) => void + removeItem: (key: string) => void } /** diff --git a/packages/core/useBreakpoints/index.ts b/packages/core/useBreakpoints/index.ts index b803d784465..1a45aecec85 100644 --- a/packages/core/useBreakpoints/index.ts +++ b/packages/core/useBreakpoints/index.ts @@ -89,13 +89,13 @@ export function useBreakpoints(breakpoints: Breakpoints, op export type UseBreakpointsReturn = { greater: (k: K) => ComputedRef greaterOrEqual: (k: K) => ComputedRef - smaller(k: K): ComputedRef + smaller: (k: K) => ComputedRef smallerOrEqual: (k: K) => ComputedRef - between(a: K, b: K): ComputedRef - isGreater(k: K): boolean - isGreaterOrEqual(k: K): boolean - isSmaller(k: K): boolean - isSmallerOrEqual(k: K): boolean - isInBetween(a: K, b: K): boolean - current(): ComputedRef + between: (a: K, b: K) => ComputedRef + isGreater: (k: K) => boolean + isGreaterOrEqual: (k: K) => boolean + isSmaller: (k: K) => boolean + isSmallerOrEqual: (k: K) => boolean + isInBetween: (a: K, b: K) => boolean + current: () => ComputedRef } & Record> diff --git a/packages/core/useEventListener/index.ts b/packages/core/useEventListener/index.ts index 4f14aacd046..782dff805ce 100644 --- a/packages/core/useEventListener/index.ts +++ b/packages/core/useEventListener/index.ts @@ -6,8 +6,8 @@ import { unrefElement } from '../unrefElement' import { defaultWindow } from '../_configurable' interface InferEventTarget { - addEventListener(event: Events, fn?: any, options?: any): any - removeEventListener(event: Events, fn?: any, options?: any): any + addEventListener: (event: Events, fn?: any, options?: any) => any + removeEventListener: (event: Events, fn?: any, options?: any) => any } export type WindowEventName = keyof WindowEventMap diff --git a/packages/core/useFetch/index.ts b/packages/core/useFetch/index.ts index bf64f3ec156..cfbf2371b66 100644 --- a/packages/core/useFetch/index.ts +++ b/packages/core/useFetch/index.ts @@ -72,20 +72,20 @@ export interface UseFetchReturn { onFetchFinally: EventHookOn // methods - get(): UseFetchReturn & PromiseLike> - post(payload?: MaybeRefOrGetter, type?: string): UseFetchReturn & PromiseLike> - put(payload?: MaybeRefOrGetter, type?: string): UseFetchReturn & PromiseLike> - delete(payload?: MaybeRefOrGetter, type?: string): UseFetchReturn & PromiseLike> - patch(payload?: MaybeRefOrGetter, type?: string): UseFetchReturn & PromiseLike> - head(payload?: MaybeRefOrGetter, type?: string): UseFetchReturn & PromiseLike> - options(payload?: MaybeRefOrGetter, type?: string): UseFetchReturn & PromiseLike> + get: () => UseFetchReturn & PromiseLike> + post: (payload?: MaybeRefOrGetter, type?: string) => UseFetchReturn & PromiseLike> + put: (payload?: MaybeRefOrGetter, type?: string) => UseFetchReturn & PromiseLike> + delete: (payload?: MaybeRefOrGetter, type?: string) => UseFetchReturn & PromiseLike> + patch: (payload?: MaybeRefOrGetter, type?: string) => UseFetchReturn & PromiseLike> + head: (payload?: MaybeRefOrGetter, type?: string) => UseFetchReturn & PromiseLike> + options: (payload?: MaybeRefOrGetter, type?: string) => UseFetchReturn & PromiseLike> // type - json(): UseFetchReturn & PromiseLike> - text(): UseFetchReturn & PromiseLike> - blob(): UseFetchReturn & PromiseLike> - arrayBuffer(): UseFetchReturn & PromiseLike> - formData(): UseFetchReturn & PromiseLike> + json: () => UseFetchReturn & PromiseLike> + text: () => UseFetchReturn & PromiseLike> + blob: () => UseFetchReturn & PromiseLike> + arrayBuffer: () => UseFetchReturn & PromiseLike> + formData: () => UseFetchReturn & PromiseLike> } type DataType = 'text' | 'json' | 'blob' | 'arrayBuffer' | 'formData' diff --git a/packages/core/useMemoize/index.md b/packages/core/useMemoize/index.md index c8f36d9897d..7a52b692345 100644 --- a/packages/core/useMemoize/index.md +++ b/packages/core/useMemoize/index.md @@ -70,22 +70,22 @@ export interface MemoizeCache { /** * Get value for key */ - get (key: Key): Value | undefined + get: (key: Key) => Value | undefined /** * Set value for key */ - set (key: Key, value: Value): void + set: (key: Key, value: Value) => void /** * Return flag if key exists */ - has (key: Key): boolean + has: (key: Key) => boolean /** * Delete value for key */ - delete (key: Key): void + delete: (key: Key) => void /** * Clear cache */ - clear (): void + clear: () => void } ``` diff --git a/packages/core/useMemoize/index.ts b/packages/core/useMemoize/index.ts index 2789ac30c5e..38674ab870f 100644 --- a/packages/core/useMemoize/index.ts +++ b/packages/core/useMemoize/index.ts @@ -10,23 +10,23 @@ export interface UseMemoizeCache { /** * Get value for key */ - get(key: Key): Value | undefined + get: (key: Key) => Value | undefined /** * Set value for key */ - set(key: Key, value: Value): void + set: (key: Key, value: Value) => void /** * Return flag if key exists */ - has(key: Key): boolean + has: (key: Key) => boolean /** * Delete value for key */ - delete(key: Key): void + delete: (key: Key) => void /** * Clear cache */ - clear(): void + clear: () => void } /** @@ -58,19 +58,19 @@ export interface UseMemoizeReturn { /** * Call memoized function and update cache */ - load(...args: Args): Result + load: (...args: Args) => Result /** * Delete cache of given arguments */ - delete(...args: Args): void + delete: (...args: Args) => void /** * Clear cache */ - clear(): void + clear: () => void /** * Generate cache key for given arguments */ - generateKey(...args: Args): CacheKey + generateKey: (...args: Args) => CacheKey /** * Cache container */ diff --git a/packages/core/usePointerLock/index.ts b/packages/core/usePointerLock/index.ts index ec5d3538408..6a4e04f500d 100644 --- a/packages/core/usePointerLock/index.ts +++ b/packages/core/usePointerLock/index.ts @@ -7,20 +7,16 @@ import type { MaybeElementRef } from '../unrefElement' import type { ConfigurableDocument } from '../_configurable' import { defaultDocument } from '../_configurable' -declare global { - interface PointerLockOptions { - unadjustedMovement?: boolean - } - - interface Element { - requestPointerLock(options?: PointerLockOptions): Promise | void - } -} +// declare global { +// interface PointerLockOptions { +// unadjustedMovement?: boolean +// } +// } type MaybeHTMLElement = HTMLElement | undefined | null export interface UsePointerLockOptions extends ConfigurableDocument { - pointerLockOptions?: PointerLockOptions + // pointerLockOptions?: PointerLockOptions } /** @@ -31,7 +27,7 @@ export interface UsePointerLockOptions extends ConfigurableDocument { * @param options */ export function usePointerLock(target?: MaybeElementRef, options: UsePointerLockOptions = {}) { - const { document = defaultDocument, pointerLockOptions } = options + const { document = defaultDocument } = options const isSupported = useSupported(() => document && 'pointerLockElement' in document) @@ -60,7 +56,10 @@ export function usePointerLock(target?: MaybeElementRef, optio }) } - async function lock(e: MaybeElementRef | Event, options?: PointerLockOptions) { + async function lock( + e: MaybeElementRef | Event, + // options?: PointerLockOptions, + ) { if (!isSupported.value) throw new Error('Pointer Lock API is not supported by your browser.') @@ -68,7 +67,7 @@ export function usePointerLock(target?: MaybeElementRef, optio targetElement = e instanceof Event ? unrefElement(target) ?? triggerElement.value : unrefElement(e) if (!targetElement) throw new Error('Target element undefined.') - targetElement.requestPointerLock(options ?? pointerLockOptions) + targetElement.requestPointerLock() return await until(element).toBe(targetElement) } diff --git a/packages/core/useRefHistory/index.ts b/packages/core/useRefHistory/index.ts index e3e17e340c3..24e8594e146 100644 --- a/packages/core/useRefHistory/index.ts +++ b/packages/core/useRefHistory/index.ts @@ -56,26 +56,26 @@ export interface UseRefHistoryReturn extends UseManualRefHistor /** * Pause change tracking */ - pause(): void + pause: () => void /** * Resume change tracking * * @param [commit] if true, a history record will be create after resuming */ - resume(commit?: boolean): void + resume: (commit?: boolean) => void /** * A sugar for auto pause and auto resuming within a function scope * * @param fn */ - batch(fn: (cancel: Fn) => void): void + batch: (fn: (cancel: Fn) => void) => void /** * Clear the data and stop the watch */ - dispose(): void + dispose: () => void } /** diff --git a/packages/core/useScreenOrientation/index.ts b/packages/core/useScreenOrientation/index.ts index 89dbefc65de..8918f9b58c7 100644 --- a/packages/core/useScreenOrientation/index.ts +++ b/packages/core/useScreenOrientation/index.ts @@ -11,11 +11,11 @@ export type OrientationType = 'portrait-primary' | 'portrait-secondary' | 'lands export type OrientationLockType = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary' export interface ScreenOrientation extends EventTarget { - lock(orientation: OrientationLockType): Promise - unlock(): void + lock: (orientation: OrientationLockType) => Promise + unlock: () => void readonly type: OrientationType readonly angle: number - addEventListener(type: 'change', listener: (this: this, ev: Event) => any, useCapture?: boolean): void + addEventListener: (type: 'change', listener: (this: this, ev: Event) => any, useCapture?: boolean) => void } /** diff --git a/packages/core/useSpeechRecognition/types.ts b/packages/core/useSpeechRecognition/types.ts index 99be0895cfa..b4bd2735cd7 100644 --- a/packages/core/useSpeechRecognition/types.ts +++ b/packages/core/useSpeechRecognition/types.ts @@ -17,9 +17,9 @@ interface SpeechGrammar { interface SpeechGrammarList { readonly length: number - addFromString(string: string, weight?: number): void - addFromURI(src: string, weight?: number): void - item(index: number): SpeechGrammar + addFromString: (string: string, weight?: number) => void + addFromURI: (src: string, weight?: number) => void + item: (index: number) => SpeechGrammar [index: number]: SpeechGrammar } @@ -34,17 +34,17 @@ interface SpeechRecognitionEvent extends Event { } interface SpeechRecognitionEventMap { - 'audioend': Event - 'audiostart': Event - 'end': Event - 'error': SpeechRecognitionErrorEvent - 'nomatch': SpeechRecognitionEvent - 'result': SpeechRecognitionEvent - 'soundend': Event - 'soundstart': Event - 'speechend': Event - 'speechstart': Event - 'start': Event + audioend: Event + audiostart: Event + end: Event + error: SpeechRecognitionErrorEvent + nomatch: SpeechRecognitionEvent + result: SpeechRecognitionEvent + soundend: Event + soundstart: Event + speechend: Event + speechstart: Event + start: Event } export interface SpeechRecognition extends EventTarget { @@ -64,11 +64,9 @@ export interface SpeechRecognition extends EventTarget { onspeechend: ((this: SpeechRecognition, ev: Event) => any) | null onspeechstart: ((this: SpeechRecognition, ev: Event) => any) | null onstart: ((this: SpeechRecognition, ev: Event) => any) | null - abort(): void - start(): void - stop(): void - addEventListener(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void - removeEventListener(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions): void - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void + abort: () => void + start: () => void + stop: () => void + addEventListener: ((type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void) + removeEventListener: ((type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void) } diff --git a/packages/core/useStorage/index.ts b/packages/core/useStorage/index.ts index cf1d588f313..3ae9b751618 100644 --- a/packages/core/useStorage/index.ts +++ b/packages/core/useStorage/index.ts @@ -9,13 +9,13 @@ import { defaultWindow } from '../_configurable' import { guessSerializerType } from './guess' export interface Serializer { - read(raw: string): T - write(value: T): string + read: (raw: string) => T + write: (value: T) => string } export interface SerializerAsync { - read(raw: string): Awaitable - write(value: T): Awaitable + read: (raw: string) => Awaitable + write: (value: T) => Awaitable } export const StorageSerializers: Record<'boolean' | 'object' | 'number' | 'any' | 'string' | 'map' | 'set' | 'date', Serializer> = { @@ -199,7 +199,7 @@ export function useStorage storage!.removeItem(key) } else { - const serialized = serializer.write(v) + const serialized = serializer.write(v as any) const oldValue = storage!.getItem(key) if (oldValue !== serialized) { storage!.setItem(key, serialized) diff --git a/packages/core/useTemplateRefsList/index.ts b/packages/core/useTemplateRefsList/index.ts index da45c30f8ef..cfa758fc8af 100644 --- a/packages/core/useTemplateRefsList/index.ts +++ b/packages/core/useTemplateRefsList/index.ts @@ -2,7 +2,7 @@ import type { Ref } from 'vue-demi' import { onBeforeUpdate, ref } from 'vue-demi' export type TemplateRefsList = T[] & { - set(el: Object | null): void + set: (el: Object | null) => void } export function useTemplateRefsList(): Readonly>>> { diff --git a/packages/electron/useIpcRenderer/index.ts b/packages/electron/useIpcRenderer/index.ts index 846ed8aad47..9bd8a708308 100644 --- a/packages/electron/useIpcRenderer/index.ts +++ b/packages/electron/useIpcRenderer/index.ts @@ -17,35 +17,35 @@ export interface UseIpcRendererReturn { * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener */ - on(channel: string, listener: IpcRendererListener): IpcRenderer + on: (channel: string, listener: IpcRendererListener) => IpcRenderer /** * Adds a one time listener function for the event. This listener is invoked only the next time a message is sent to channel, after which it is removed. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereroncechannel-listener */ - once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): IpcRenderer + once: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void) => IpcRenderer /** * Removes the specified listener from the listener array for the specified channel. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener */ - removeListener(channel: string, listener: (...args: any[]) => void): IpcRenderer + removeListener: (channel: string, listener: (...args: any[]) => void) => IpcRenderer /** * Removes all listeners, or those of the specified channel. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovealllistenerschannel */ - removeAllListeners(channel: string): IpcRenderer + removeAllListeners: (channel: string) => IpcRenderer /** * Send an asynchronous message to the main process via channel, along with arguments. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendchannel-args */ - send(channel: string, ...args: any[]): void + send: (channel: string, ...args: any[]) => void /** * Returns Promise - Resolves with the response from the main process. @@ -54,7 +54,7 @@ export interface UseIpcRendererReturn { * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args */ - invoke(channel: string, ...args: any[]): Ref + invoke: (channel: string, ...args: any[]) => Ref /** * Returns any - The value sent back by the ipcMain handler. @@ -62,28 +62,28 @@ export interface UseIpcRendererReturn { * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendsyncchannel-args */ - sendSync(channel: string, ...args: any[]): Ref + sendSync: (channel: string, ...args: any[]) => Ref /** * Send a message to the main process, optionally transferring ownership of zero or more MessagePort objects. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererpostmessagechannel-message-transfer */ - postMessage(channel: string, message: any, transfer?: MessagePort[]): void + postMessage: (channel: string, message: any, transfer?: MessagePort[]) => void /** * Sends a message to a window with webContentsId via channel. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtowebcontentsid-channel-args */ - sendTo(webContentsId: number, channel: string, ...args: any[]): void + sendTo: (webContentsId: number, channel: string, ...args: any[]) => void /** * Like ipcRenderer.send but the event will be sent to the element in the host page instead of the main process. * * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtohostchannel-args */ - sendToHost(channel: string, ...args: any[]): void + sendToHost: (channel: string, ...args: any[]) => void } /** diff --git a/packages/integrations/useIDBKeyval/index.ts b/packages/integrations/useIDBKeyval/index.ts index 00d46d99433..90d676c598f 100644 --- a/packages/integrations/useIDBKeyval/index.ts +++ b/packages/integrations/useIDBKeyval/index.ts @@ -37,7 +37,7 @@ export interface UseIDBOptions extends ConfigurableFlush { export interface UseIDBKeyvalReturn { data: RemovableRef isFinished: Ref - set(value: T): Promise + set: (value: T) => Promise } /** diff --git a/packages/integrations/useSortable/index.ts b/packages/integrations/useSortable/index.ts index bc47ed9dda0..ab23209dde7 100644 --- a/packages/integrations/useSortable/index.ts +++ b/packages/integrations/useSortable/index.ts @@ -18,8 +18,7 @@ export interface UseSortableReturn { * @param name a Sortable.Options property. * @param value a value. */ - option(name: K, value: Sortable.Options[K]): void - option(name: K): Sortable.Options[K] + option: ((name: K, value: Sortable.Options[K]) => void) & ((name: K) => Sortable.Options[K]) } export type UseSortableOptions = Options & ConfigurableDocument @@ -28,6 +27,7 @@ export function useSortable(selector: string, list: MaybeRefOrGetter, options?: UseSortableOptions): UseSortableReturn export function useSortable(el: MaybeRefOrGetter, list: MaybeRefOrGetter, options?: UseSortableOptions): UseSortableReturn + /** * Wrapper for sortablejs. * @param el @@ -72,7 +72,11 @@ export function useSortable( tryOnScopeDispose(stop) - return { stop, start, option } + return { + stop, + start, + option: option as UseSortableReturn['option'], + } } export function moveArrayElement( diff --git a/packages/shared/computedWithControl/index.ts b/packages/shared/computedWithControl/index.ts index 3c35fd6c18c..a73359ea3b4 100644 --- a/packages/shared/computedWithControl/index.ts +++ b/packages/shared/computedWithControl/index.ts @@ -6,7 +6,7 @@ export interface ComputedWithControlRefExtra { /** * Force update the computed value. */ - trigger(): void + trigger: () => void } export interface ComputedRefWithControl extends ComputedRef, ComputedWithControlRefExtra {} diff --git a/packages/shared/until/index.ts b/packages/shared/until/index.ts index 906126c3d30..7e07a16474a 100644 --- a/packages/shared/until/index.ts +++ b/packages/shared/until/index.ts @@ -36,16 +36,15 @@ export interface UntilToMatchOptions { } export interface UntilBaseInstance { - toMatch( + toMatch: (( condition: (v: T) => v is U, options?: UntilToMatchOptions - ): Not extends true ? Promise> : Promise - toMatch( + ) => Not extends true ? Promise> : Promise) & (( condition: (v: T) => boolean, options?: UntilToMatchOptions - ): Promise - changed(options?: UntilToMatchOptions): Promise - changedTimes(n?: number, options?: UntilToMatchOptions): Promise + ) => Promise) + changed: (options?: UntilToMatchOptions) => Promise + changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise } type Falsy = false | void | null | undefined | 0 | 0n | '' @@ -53,17 +52,17 @@ type Falsy = false | void | null | undefined | 0 | 0n | '' export interface UntilValueInstance extends UntilBaseInstance { readonly not: UntilValueInstance - toBe

(value: MaybeRefOrGetter

, options?: UntilToMatchOptions): Not extends true ? Promise : Promise

- toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise : Promise> - toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise> : Promise - toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise> : Promise - toBeNaN(options?: UntilToMatchOptions): Promise + toBe:

(value: MaybeRefOrGetter

, options?: UntilToMatchOptions) => Not extends true ? Promise : Promise

+ toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise : Promise> + toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise> : Promise + toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise> : Promise + toBeNaN: (options?: UntilToMatchOptions) => Promise } export interface UntilArrayInstance extends UntilBaseInstance { readonly not: UntilArrayInstance - toContains(value: MaybeRefOrGetter>>, options?: UntilToMatchOptions): Promise + toContains: (value: MaybeRefOrGetter>>, options?: UntilToMatchOptions) => Promise } function createUntil(r: any, isNot = false) { @@ -179,7 +178,7 @@ function createUntil(r: any, isNot = false) { if (Array.isArray(toValue(r))) { const instance: UntilArrayInstance = { - toMatch, + toMatch: toMatch as any, toContains, changed, changedTimes, @@ -191,7 +190,7 @@ function createUntil(r: any, isNot = false) { } else { const instance: UntilValueInstance = { - toMatch, + toMatch: toMatch as any, toBe, toBeTruthy: toBeTruthy as any, toBeNull: toBeNull as any, diff --git a/packages/shared/utils/types.ts b/packages/shared/utils/types.ts index 7d88b0dc5ae..cde7bc8a68c 100644 --- a/packages/shared/utils/types.ts +++ b/packages/shared/utils/types.ts @@ -74,7 +74,7 @@ export type ArgumentsType = T extends (...args: infer U) => any ? U : never */ export type Awaited = T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode - T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped + T extends object & { then: (onfulfilled: infer F, ...args: infer _) => any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument Awaited : // recursively unwrap the value never : // the argument to `then` was not callable