Skip to content

Vue 3 support #2670

Closed
Closed
@cexbrayat

Description

@cexbrayat

I apoligize if there is a tracking issue for this, but I could not find one.

Is your feature request related to a problem? Please describe.

Currently, we can not use vee-validate with Vue 3 in a CLI project with TypeScript.
There are errors on :

  • yarn build
  • yarn serve and at runtime

When using [email protected] with Vue 3 (3.0.0-alpha.7 at the moment), the TyepScript compiler throws on yarn build:

ERROR in /Users/.../my-project/node_modules/vee-validate/dist/types/components/Observer.d.ts(19,49):
19:49 Cannot find module 'vue/types/vue'.
    17 |     failed: boolean;
    18 | }
  > 19 | export declare const ValidationObserver: import("vue/types/vue").ExtendedVue<Vue & {
       |                                                 ^
    20 |     $_veeObserver: VeeObserver;
    21 |     $vnode: VNodeWithVeeContext;
    22 | }, {

 error  in /Users/.../my-project/node_modules/vee-validate/dist/types/components/Provider.d.ts

ERROR in /Users/.../my-project/node_modules/vee-validate/dist/types/components/Provider.d.ts(3,49):
3:49 Cannot find module 'vue/types/vue'.
    1 | import Vue from 'vue';
    2 | import { ValidationFlags, ValidationResult, VeeObserver, VNodeWithVeeContext } from '../types';
  > 3 | export declare const ValidationProvider: import("vue/types/vue").ExtendedVue<Vue & {
      |                                                 ^
    4 |     $_veeObserver: VeeObserver;
    5 |     _needsValidation: boolean;
    6 |     _inputEventName: string;

 error  in /Users/.../my-project/node_modules/vee-validate/dist/types/localeChanged.d.ts

ERROR in /Users/.../my-project/node_modules/vee-validate/dist/types/localeChanged.d.ts(2,33):
2:33 Cannot find module 'vue/types/vue'.
    1 | import Vue from 'vue';
  > 2 | declare const EVENT_BUS: import("vue/types/vue").CombinedVueInstance<Vue, object, object, object, Record<never, any>>;
      |                                 ^
    3 | export declare function localeChanged(): void;
    4 | export { EVENT_BUS };
    5 |

 error  in /Users/.../my-project/node_modules/vee-validate/dist/types/types.d.ts

ERROR in /Users/.../my-project/node_modules/vee-validate/dist/types/types.d.ts(10,44):
10:44 Cannot use namespace 'Vue' as a type.
     8 |     regenerateMap?: Record<string, () => string>;
     9 | }
  > 10 | export declare type VueValidationContext = Vue & {
       |                                            ^
    11 |     $_veeObserver?: VeeObserver;
    12 | };
    13 | export declare type Locator = {

 error  in /Users/.../my-project/node_modules/vee-validate/dist/types/types.d.ts

ERROR in /Users/.../my-project/node_modules/vee-validate/dist/types/types.d.ts(75,14):
75:14 Cannot use namespace 'Vue' as a type.
    73 | }
    74 | export declare type VNodeWithVeeContext = VNode & {
  > 75 |     context: Vue & {
       |              ^
    76 |         $_veeObserver?: VeeObserver;
    77 |     };
    78 | };

Then yarn serve also complains:

 WARNING  Compiled with 3 warnings                                                                                                10:32:20 AM

 warning  in ./node_modules/vee-validate/dist/vee-validate.esm.js

"export 'default' (imported as 'Vue') was not found in 'vue'

 warning  in ./node_modules/vee-validate/dist/vee-validate.esm.js

"export 'default' (imported as 'Vue') was not found in 'vue'

 warning  in ./node_modules/vee-validate/dist/vee-validate.esm.js

"export 'default' (imported as 'Vue') was not found in 'vue'

and then it throws at runtime:

TypeError: vue__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor
chunk-vendors.js line 2085 > eval:866:17
    <anonyme> vee-validate.esm.js:853
    js chunk-vendors.js:2085

What is your plan for Vue 3 support?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔼 v4.0Will be handled in the next major version🛳 In PRThis issue is being addressed in a PR

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions