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

TypeScript errors with vue-tsc --noEmit #763

Closed
Shinigami92 opened this issue Nov 3, 2021 · 6 comments
Closed

TypeScript errors with vue-tsc --noEmit #763

Shinigami92 opened this issue Nov 3, 2021 · 6 comments

Comments

@Shinigami92
Copy link

Shinigami92 commented Nov 3, 2021

Reproduction

On demand

Steps to reproduce the behavior

  1. Create a Vue2 project
  2. Setup a store / use pinia
  3. Run yarn vue-tsc --noEmit

Expected behavior

No compile time TS errors

Actual behavior

$ yarn vue-tsc --noEmit
node_modules/pinia/dist/pinia.d.ts:3:10 - error TS2305: Module '"vue-demi"' has no exported member 'DebuggerEvent'.

3 import { DebuggerEvent } from 'vue-demi';
           ~~~~~~~~~~~~~

node_modules/pinia/dist/pinia.d.ts:5:10 - error TS2305: Module '"vue-demi"' has no exported member 'Plugin'.

5 import { Plugin as Plugin_2 } from 'vue-demi';
           ~~~~~~

node_modules/pinia/dist/pinia.d.ts:516:42 - error TS2315: Type 'App' is not generic.

516 export declare const PiniaPlugin: ((app: App<any>, ...options: any[]) => any) & {
                                             ~~~~~~~~

node_modules/pinia/dist/pinia.d.ts:517:22 - error TS2315: Type 'App' is not generic.

517     install?: ((app: App<any>, ...options: any[]) => any) | undefined;
                         ~~~~~~~~


Found 4 errors.
@posva
Copy link
Member

posva commented Nov 3, 2021

Duplicate of #758

@posva posva marked this as a duplicate of #758 Nov 3, 2021
@posva posva closed this as completed Nov 3, 2021
@Shinigami92
Copy link
Author

Much more type-safe solution for me is using yarn patch

diff --git a/dist/pinia.d.ts b/dist/pinia.d.ts
index 947b13cfe11c851358d9ef3cc8b97100f3db31b6..88fabc1da4a9c6ef9f8007836941448b253d4df7 100644
--- a/dist/pinia.d.ts
+++ b/dist/pinia.d.ts
@@ -1,7 +1,9 @@
 import { App } from 'vue-demi';
 import { ComputedRef } from 'vue-demi';
+// @ts-ignore
 import { DebuggerEvent } from 'vue-demi';
 import { EffectScope } from 'vue-demi';
+// @ts-ignore
 import { Plugin as Plugin_2 } from 'vue-demi';
 import { Ref } from 'vue-demi';
 import { ToRefs } from 'vue-demi';
@@ -513,7 +515,9 @@ export declare interface PiniaCustomStateProperties<S extends StateTree = StateT
 /**
  * @deprecated use `PiniaVuePlugin` instead.
  */
+// @ts-ignore
 export declare const PiniaPlugin: ((app: App<any>, ...options: any[]) => any) & {
+    // @ts-ignore
     install?: ((app: App<any>, ...options: any[]) => any) | undefined;
 };

@posva
Copy link
Member

posva commented Nov 3, 2021

Adapting this requires a few changes:

@Shinigami92
Copy link
Author

Patch for 2.0.1

diff --git a/dist/pinia.d.ts b/dist/pinia.d.ts
index e0b5f993dc45072df1d0a8ad110d22785d8d663d..6f8ca69c1221566998f4d5040bf53a08d0432355 100644
--- a/dist/pinia.d.ts
+++ b/dist/pinia.d.ts
@@ -1,7 +1,9 @@
 import { App } from 'vue-demi';
 import { ComputedRef } from 'vue-demi';
+// @ts-ignore
 import { DebuggerEvent } from 'vue-demi';
 import { EffectScope } from 'vue-demi';
+// @ts-ignore
 import { Plugin as Plugin_2 } from 'vue-demi';
 import { Ref } from 'vue-demi';
 import { ToRefs } from 'vue-demi';

Maybe I could look into that later if I have some time, but not sure.
For now I use the local patch, cause in the long run we switch to pinia cause we want to migrate to Vue 3 anyways someday

@Shinigami92
Copy link
Author

Updated to 2.0.2 and everything is working now without patch
Thx 🎉

@posva
Copy link
Member

posva commented Nov 4, 2021

Nice! 💪

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

No branches or pull requests

2 participants