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

TS with decorators #198

Open
alvaro-canepa opened this issue Jun 7, 2020 · 0 comments
Open

TS with decorators #198

alvaro-canepa opened this issue Jun 7, 2020 · 0 comments

Comments

@alvaro-canepa
Copy link

Using TS with decorators is not possible to set the notificacions object, as say the doc. This must be a function type, returning the object options.
But TS give error Property $error does not exists.

I made a mixin to use it.

// main.ts
import Component from "vue-class-component";
Component.registerHooks(["notifications"]);

// mixins/notify.ts
import { Component, Vue } from "vue-property-decorator";

@Component
export default class Notify extends Vue {
  notifications() {
    return {
      $error: {
        type: "error",
        title: "",
        message: ""
      },
      $warning: {
        type: "warning",
        title: "",
        message: ""
      },
      $info: {
        type: "info",
        title: "",
        message: ""
      },
      $success: {
        type: "success",
        title: "",
        message: ""
      }
    };
  }
}

I think the fixed was in line 80

const methodConfig = pluginOptions ? pluginOptions[methodName] : {}

pluginOptions[methodName] must be checked if is a function.
something like

const pluginOptionsData = typeof pluginOptions === 'function' ? pluginOptions.call() : pluginOptions;
const methodConfig = pluginOptionsData ? pluginOptionsData[methodName] : {};
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

1 participant