justinkames / vuejs-logger

Provides customizable logging functionality for Vue.js. Compatible with Vue2.
MIT License
244 stars 50 forks source link

not usable with vue cli setup typescript project #38

Open dennissterzenbach opened 4 years ago

dennissterzenbach commented 4 years ago

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?

thomergil commented 4 years ago

I have the same problem.

thomergil commented 4 years ago

An inelegant solution:

Vue.use(VueLogger as any, options);

ageddesi commented 4 years ago

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

xbill82 commented 3 years ago

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

justinkames commented 3 years ago

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 commented 3 years ago

@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 ;).

jenow commented 3 years ago

I personally still have the error with 1.5.5

tsposato commented 3 years ago

I also have the same issue on 1.5.4 & 1.5.5.