vuejs-logger icon indicating copy to clipboard operation
vuejs-logger copied to clipboard

not usable with vue cli setup typescript project

Open dennissterzenbach opened this issue 4 years ago • 8 comments

I setup a new vue project using the cli, including TypeScript support and wanted to add vuejs-logger. I'm already using the latest version, which includes the type def (.d.ts) file. That file is recognised by VSCode, too.

However I can't get the project to compile.

this is the main.ts:

import Vue from 'vue';
import VueLogger from 'vuejs-logger';
import App from './App.vue';
import router from './router';
import store from './store';

Vue.config.productionTip = false;

const isProduction = process.env.NODE_ENV === 'production';

const options = {
    isEnabled: true,
    logLevel : isProduction ? 'error' : 'debug',
    stringifyArguments : false,
    showLogLevel : true,
    showMethodName : true,
    separator: '|',
    showConsoleColors: true
};

Vue.use(VueLogger, options);

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app');

Complete error output:

No overload matches this call.
  Overload 1 of 2, '(plugin: PluginObject<{ isEnabled: boolean; logLevel: string; stringifyArguments: boolean; showLogLevel: boolean; showMethodName: boolean; separator: string; showConsoleColors: boolean; }> | PluginFunction<...>, options?: { ...; } | undefined): VueConstructor<...>', gave the following error.
    Argument of type 'typeof import("........../node_modules/vuejs-logger/dist/index")' is not assignable to parameter of type 'PluginObject<{ isEnabled: boolean; logLevel: string; stringifyArguments: boolean; showLogLevel: boolean; showMethodName: boolean; separator: string; showConsoleColors: boolean; }> | PluginFunction<...>'.
      Property 'install' is missing in type 'typeof import("........../node_modules/vuejs-logger/dist/index")' but required in type 'PluginObject<{ isEnabled: boolean; logLevel: string; stringifyArguments: boolean; showLogLevel: boolean; showMethodName: boolean; separator: string; showConsoleColors: boolean; }>'.

  Overload 2 of 2, '(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): VueConstructor<Vue>', gave the following error.
    Argument of type 'typeof import("........../node_modules/vuejs-logger/dist/index")' is not assignable to parameter of type 'PluginObject<any> | PluginFunction<any>'.
      Property 'install' is missing in type 'typeof import("........../node_modules/vuejs-logger/dist/index")' but required in type 'PluginObject<any>'.
};

Any suggestions?

dennissterzenbach avatar Jun 23 '20 18:06 dennissterzenbach

I have the same problem.

thomergil avatar Jul 02 '20 07:07 thomergil

An inelegant solution:

Vue.use(VueLogger as any, options);

thomergil avatar Jul 02 '20 07:07 thomergil

I have just done a pull request that I believe fixes this issue.

ageddesi avatar Oct 08 '20 18:10 ageddesi

We have the same problem here at Kuzzle and are currently using the same solution as thomergil. Please, merge the PR from @ageddesi 🙏

xbill82 avatar Nov 23 '20 14:11 xbill82

We have the same problem here at Kuzzle and are currently using the same solution as thomergil. Please, merge the PR from @ageddesi

Let me have a look!

justinkames avatar Nov 23 '20 14:11 justinkames

@ageddesi @xbill82 I merged the PR and released the package as 1.5.5 on NPM.

Can you confirm your issue is solved? Because in my sample TS project it unfortunately isn't.

I'm using

"dependencies": { "vue": "^2.6.11", "vue-class-component": "^7.2.3", "vue-property-decorator": "^8.4.2", "vuejs-logger": "1.5.5" }, "devDependencies": { "@vue/cli-plugin-typescript": "~4.5.0", "@vue/cli-service": "~4.5.0", "typescript": "~3.9.3", "vue-template-compiler": "^2.6.11"

Please let me know ;).

justinkames avatar Nov 23 '20 16:11 justinkames

I personally still have the error with 1.5.5

jenow avatar Nov 26 '20 08:11 jenow

I also have the same issue on 1.5.4 & 1.5.5.

tsposato avatar Jun 28 '21 01:06 tsposato