Skip to content

Commit

Permalink
@uppy/core: set default for Body generic (#5244)
Browse files Browse the repository at this point in the history
* @uppy/core: set default for Body generic

* Update angular example
  • Loading branch information
Murderlon authored Jun 11, 2024
1 parent 9ff3746 commit 181ea6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions examples/angular-example/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/core/src/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 181ea6d

Please sign in to comment.