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

Fixed options object typings for javascript plugins inside plugin.d.ts #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arv-asommer
Copy link

Solves this issue: #1

initialOptions: object;
options: object;
initialOptions: {
[key: string]: any;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any is bad; could it also be an object?

or even better a proper type defined.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you have to use any here since you also want the user to use their own types here...
Another way might be to put a generic onto the Plugin class itself. Then it might be used like this:

export default class CustomStorefrontPlugin extends Plugin<{ option1: string; option2: CustomType | null }> {
  static options = {
    option1 = 'Default string value',
    option2 = null
},

  init() {...}

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

Successfully merging this pull request may close these issues.

2 participants