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

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

Closed
7 tasks done
lsdsjy opened this issue Sep 20, 2022 · 6 comments · May be fixed by vueuse/vue-demi#245
Closed
7 tasks done

Comments

@lsdsjy
Copy link
Contributor

lsdsjy commented Sep 20, 2022

Describe the bug

Running vue-tsc in a project with vue of version 2.7 would report errors like this:

node_modules/@vueuse/shared/index.d.ts:200:26 - error TS2339: Property 'flush' does not exist on type 'WatchOptions'.

200     flush?: WatchOptions['flush'];

It seems that vue 2.7 exports WatchOptions for Options API, not for Composition API:

// node_modules/vue/types/index.d.ts
export {
  ...
  WatchOptions,
  WatchOptionsWithHandler,
  DirectiveFunction,
  DirectiveOptions
} from './options'

which has no flush property.
A possible fix is to re-export WatchOptions from vue/types/v3-generated in vue-demi for v2.7 like:

// vue-demi/lib/v2.7/index.d.ts
export * from 'vue'
export type { WatchOptions } from 'vue/types/v3-generated'

@antfu Any thoughts?

Reproduction

https://stackblitz.com/edit/vitejs-vite-z2pxyv?file=src/a.ts

Run npx vue-tsc

System Info

@vueuse/core: ^9.2.0 => 9.2.0 
    vue: ^2.7.3 => 2.7.10 

on StackBlitz

Used Package Manager

npm

Validations

@Holi0317
Copy link
Contributor

Holi0317 commented Oct 25, 2022

Got same issue with vue 2.7.13.

I am working around this issue by as any the watch options which makes typescript happy.

I think this is issue with vue instead of demi coz the type exported in vue 2.7 is (somehow magically?) compatible with both v3 and v2. Should we open issue on vue repo?

@vuthanhbayit
Copy link

same issue!

@stale
Copy link

stale bot commented Jan 30, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Jan 30, 2023
@Dmitry-zh
Copy link

Have same issue.
@lsdsjy thank you for solution

Temporary added patch:

diff --git a/node_modules/vue-demi/lib/index.d.ts b/node_modules/vue-demi/lib/index.d.ts
index 897b4c5..6cdfb78 100644
--- a/node_modules/vue-demi/lib/index.d.ts
+++ b/node_modules/vue-demi/lib/index.d.ts
@@ -18,6 +18,7 @@ declare const V: typeof Vue
 export declare type Plugin = PluginObject<any> | PluginFunction<any>
 export type { VNode } from 'vue'
 export * from 'vue'
+export type { WatchOptions } from 'vue/types/v3-generated'
 export { V as Vue, Vue2, isVue2, isVue3, version, install }

 // #region createApp polyfill

and added resolution in my package.json to freeze version:

"resolutions": {
        "vue-demi": "0.13.11"
    }

Hope this problem going to be solved asap

@stale
Copy link

stale bot commented Apr 14, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Apr 14, 2023
@stale
Copy link

stale bot commented Jun 13, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 13, 2023
@stale stale bot closed this as completed Jun 20, 2023
Glandos added a commit to Glandos/vue-demi that referenced this issue Sep 20, 2023
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 a pull request may close this issue.

4 participants