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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive stack depth comparing types 'Plugin_2' and 'Plugin_2' #49180

Closed
amrap030 opened this issue May 19, 2022 · 4 comments
Closed

Excessive stack depth comparing types 'Plugin_2' and 'Plugin_2' #49180

amrap030 opened this issue May 19, 2022 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@amrap030
Copy link

Bug Report

馃攷 Search Terms

  • Excessive stack depth comparing types

馃晽 Version & Regression Information

Occurs on all Typescript versions
Node: v16.15.0

馃檨 Actual behavior

Hello, I am trying to build a universal library for renderless components and composables as a plugin for Vue2 and Vue3 with the use of vue-demi. When I try to use the plugin in my Vue3 application locally via yarn link I get the following error: Excessive stack depth comparing types 'Plugin_2' and 'Plugin_2'. I am not sure if this is related to vue-demi or to typescript. The same issue is also posted here: vueuse/vue-demi#160

I already tried some solutions from other similar issues, for example changing the VSCode Typescript version to the workspace version with several versions with no luck.

This is the repository of the Plugin: https://github.com/whitelabel-market/wallet-connector-vue

The plugin is created like this:

import {
  ConnectModal,
  ConnectContent,
  ConnectTitle,
  ConnectButton,
} from "./components/modal";
import { WALLET_CONTEXT, createWallet } from "./hooks";
import type { App, Plugin } from "vue-demi";

export function WalletConnectorVue(options: any): Plugin {
  return {
    install(app: App) {
      app.component("ConnectModal", ConnectModal);
      app.component("ConnectContent", ConnectContent);
      app.component("ConnectTitle", ConnectTitle);
      app.component("ConnectButton", ConnectButton);
      app.provide(WALLET_CONTEXT, createWallet(options));
    },
  };
}

You can reproduce this when you use the library as follows in a Vue3 project with typescript:

import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import { INFURA_ID } from "./utils/constants";
import { WalletConnectorVue } from "@whitelabel-solutions/wallet-connector-vue/dist";

const app = createApp(App);

app.use(
  WalletConnectorVue({
    appName: "App Name",
    infuraId: INFURA_ID,
    chainId: 1,
    authereum: { key: "" }, // Yet required (but unused) in ConnectorUserOptions type
    fortmatic: { key: "" }, // Yet required (but unused) in ConnectorUserOptions type
  })
);

app.use(router);
app.mount("#app");

Notice that I am using the local build from the /dist folder! The /dist folder can be built with pnpm build

The VSCode intellisense also shows me this error directly:

Bildschirmfoto 2022-05-19 um 22 09 40

One thing I noticed is, that when I use this not as a plugin and just import the components directly, it works. The following example also works:

const app = createApp({
  setup() {
    provide(
      WALLET_CONTEXT,
      createWallet({
        appName: "App Name",
        infuraId: INFURA_ID,
        chainId: 1,
        authereum: { key: "" }, // Yet required (but unused) in ConnectorUserOptions type
        fortmatic: { key: "" }, // Yet required (but unused) in ConnectorUserOptions type
      })
    );
  },
  render: () => h(App),
});

Only when using this as a plugin as described above, it doesn't work. I really need help here, because I have absolutely no idea how to fix this.

馃檪 Expected behavior

No error

@amrap030
Copy link
Author

amrap030 commented May 19, 2022

I just tested this with the built version from npm (https://www.npmjs.com/package/@whitelabel-solutions/wallet-connector-vue) and this is working.

So I assume this has something to do with the local development but I am not sure why, because the /dist folder is the same as what is published on npm. So how can I make it work locally in development, because I can't always publish on npm first to check new change.

@amrap030
Copy link
Author

Hello, can anyone please help? The problem still exists.

@andrewbranch
Copy link
Member

You have two separate copies of @vue/runtime-core loaded into your program. It looks like one is a dependency of your plugin and the other is a dependency of the mondrians project. The plugin should likely declare @vue/runtime-core as a peerDependency. Or since you say it鈥檚 working in a production-like scenario, you may have it configured correctly, but loading the plugin via npm link such that all its devDependencies are installed is going to create problems locally.

@andrewbranch andrewbranch added the Working as Intended The behavior described is the intended behavior; this is not a bug label May 31, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants