Closed
Description
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
- Follow our Code of ConductRead the Contributing Guidelines.Read the docs.Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.Check that this is a concrete bug. For Q&A open a GitHub Discussion.The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Holi0317 commentedon 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 commentedon Dec 1, 2022
same issue!
stale commentedon 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.
Dmitry-zh commentedon Feb 13, 2023
Have same issue.
@lsdsjy thank you for solution
Temporary added patch:
and added resolution in my
package.json
to freeze version:Hope this problem going to be solved asap
stale commentedon 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 commentedon 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.
Re-export Options API needed type