@uppy/core: set default for Body generic (#5244)

* @uppy/core: set default for Body generic

* Update angular example
This commit is contained in:
Merlijn Vos 2024-06-11 15:41:01 +02:00 committed by GitHub
parent 9ff3746c83
commit 181ea6dfe8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

View file

@ -65,8 +65,7 @@ export class AppComponent implements OnInit {
},
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
uppy: Uppy<any, any> = new Uppy({ debug: true, autoProceed: true })
uppy = new Uppy({ debug: true, autoProceed: true })
ngOnInit(): void {
this.uppy

View file

@ -308,7 +308,7 @@ const defaultUploadState = {
* Manages plugins, state updates, acts as an event bus,
* adds/removes files and metadata.
*/
export class Uppy<M extends Meta, B extends Body> {
export class Uppy<M extends Meta, B extends Body = Record<string, never>> {
static VERSION = packageJson.version
#plugins: Record<string, UnknownPlugin<M, B>[]> = Object.create(null)

View file

@ -17,12 +17,12 @@ class TestPlugin<M extends Meta, B extends Body> extends UIPlugin<Opts, M, B> {
test('can use Uppy class without generics', async () => {
const core = new Uppy()
expectTypeOf(core).toEqualTypeOf<Uppy<Meta, Body>>()
expectTypeOf(core).toEqualTypeOf<Uppy<Meta, Record<string, never>>>()
})
test('can .use() a plugin', async () => {
const core = new Uppy().use(TestPlugin)
expectTypeOf(core).toEqualTypeOf<Uppy<Meta, Body>>()
expectTypeOf(core).toEqualTypeOf<Uppy<Meta, Record<string, never>>>()
})
test('Meta and Body generic move through the Uppy class', async () => {