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

Incomplete type definitions for BasePlugin #5121

Closed
2 tasks done
genu opened this issue Apr 26, 2024 · 1 comment
Closed
2 tasks done

Incomplete type definitions for BasePlugin #5121

genu opened this issue Apr 26, 2024 · 1 comment
Labels

Comments

@genu
Copy link

genu commented Apr 26, 2024

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

According to the BasePlugin Class, I should be able to pass 3 types:

export default class BasePlugin<
Opts extends PluginOpts,
M extends Meta,
B extends Body,
PluginState extends Record<string, unknown> = Record<string, unknown>,
> {

The type definitions, however, only allow passing in the plugin options as a type:

export class BasePlugin<TOptions extends PluginOptions = DefaultPluginOptions> {
id: string
// eslint-disable-next-line no-use-before-define
uppy: Uppy

Any reason why the type is more restrictive?

Expected behavior

I should be able to create a plugin specifying the meta and body like this:

class MyPlugin extends BasePlugin<MyPluginOptions, CustomMeta, CustomBody> {
   super(uppy, opts);

}

Actual behavior

The Base plugin only allows plugin options, which means that I'm unable strong type the meta and body inside the plugin.

Only this is allowed:

class MyPlugin extends BasePlugin<MyPluginOptions> {
    super(uppy, opts);
             ^--- is Just an Uppy type rather than a `Uppy<CustomMeta, CustomBody>`
}
@genu genu added the Bug label Apr 26, 2024
@Murderlon
Copy link
Member

In order to do a TS migration without constantly introducing new breaking type changes as we move through the codebase, we write the source in TS but do not emit type files from it. Soon we are releasing major versions for all plugins at once so the types work together. In the meantime you have to use outdated types.

@Murderlon Murderlon closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants