Skip to content

Commit

Permalink
[accel-wave] check type of attr on mount()
Browse files Browse the repository at this point in the history
  • Loading branch information
koyopro committed Dec 24, 2024
1 parent fb2cb95 commit 2b7a545
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/accel-wave/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { type Storage } from "./storages/index.js";
export { Config } from "./config.js";
export { worker } from "./worker.js";

export const mount = (model: Model, attr: string, uploaderClass: typeof BaseUploader) => {
export const mount = <T extends Model>(
model: T,
attr: keyof T & string,
uploaderClass: typeof BaseUploader
) => {
const uploader = new uploaderClass();
uploader.model = model;
uploader.attr = attr;
Expand Down
7 changes: 7 additions & 0 deletions tests/wave/mount.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BaseUploader, mount } from "accel-wave";
import type { Profile } from "../models";

test("mount", () => {
// @ts-expect-error
mount({} as Profile, "invalidPath", BaseUploader);
});

0 comments on commit 2b7a545

Please sign in to comment.