Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export Options API needed type #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Glandos
Copy link

@Glandos Glandos commented Sep 20, 2023

fix vueuse/vueuse#2232

Please adjust if importing from v3-generated is a bad practice, but the ticket has been opened for too long, and stale-bot is a bit too fast.

@antfu
Copy link
Member

antfu commented Sep 20, 2023

Maybe you could propose exporting it to the main entry of Vue 3 directly?

@Glandos
Copy link
Author

Glandos commented Sep 20, 2023

After a deeper look, I found this fix to be… not adequate.
The issue comes from the fact that vueused/shared references WatchOptions['flush']. However, this flush member doesn't exist in Vue 2. So it should be redefined in vue-demi as an augmented interface, with type never, as in:

declare vue {
	interface WatchOptions {
		flush: never
	}
}

Or something similar. However, the referenced stackblitz also give the following output when running npx vue-tsc:

node_modules/@vueuse/shared/index.d.ts:955:196 - error TS2315: Type 'WatchOptions' is not generic.

955 declare function watchArray<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T[]> | T[], cb: WatchArrayCallback<T[], Immediate extends true ? T[] | undefined : T[]>, options?: WatchOptions<Immediate>): vue_demi.WatchStopHandle;

The error is repeated multiple times, but the cause is the same: the interface is not generic. And I don't see a way to make it work reliably with a generic…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type checking failed with vue@2.7: Property 'flush' does not exist on type 'WatchOptions'
2 participants