TS error on uppy.getPlugin('Dashboard').openModal()

uppy.getPlugin(‘Dashboard).openModal()

I am getting a TypeScript error
Property 'openModal' does not exist on type 'UnknownPlugin<Meta, Record<string, never>, Record<string, unknown>>'.ts(2339)

I use // @ts-expect-error TS2339 to ignore the error but would love to know what is the best way to getPlugin()

Versions:
@uppy/aws-s3”: “^5.0.1”,

@uppy/core”: “^5.1.0”,

@uppy/dashboard”: “^5.0.2”,

@uppy/image-editor”: “^4.0.1”,

@uppy/status-bar”: “^5.0.1”,

Thanks.

You can pass a generic:

// If you defined your own generics and passed them to the Uppy class
// use those intead
import type { Meta, Body } from '@uppy/core'

uppy.getPlugin<Dashboard<Meta, Body>>('Dashboard') // any, any also fine

With the generic we get a different kind of error.
import{Body, Meta, Uppy}from '@uppy/core';
I appreciate you looking into this Merlijn!

For now you can use add any, any it’s not going to effect anything on the dashboard plugin.

Can you create a github issue that looks into making the generics on plugins optional to pass in order to simplify using getPlugin?

1 Like

no TS error with the following line:

uppy.getPlugin<Dashboard<any, any>>('Dashboard').openModal();

I will create issue over the weekend. Thanks for your help Merlijn!

Git Issue created