From 2b7a545e0945eeb3751ac8182a6085090ad53e02 Mon Sep 17 00:00:00 2001 From: koyopro Date: Wed, 25 Dec 2024 00:45:53 +0900 Subject: [PATCH] [accel-wave] check type of attr on mount() --- packages/accel-wave/src/index.ts | 6 +++++- tests/wave/mount.test-d.ts | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/wave/mount.test-d.ts diff --git a/packages/accel-wave/src/index.ts b/packages/accel-wave/src/index.ts index 3d109e6e..401e731d 100644 --- a/packages/accel-wave/src/index.ts +++ b/packages/accel-wave/src/index.ts @@ -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 = ( + model: T, + attr: keyof T & string, + uploaderClass: typeof BaseUploader +) => { const uploader = new uploaderClass(); uploader.model = model; uploader.attr = attr; diff --git a/tests/wave/mount.test-d.ts b/tests/wave/mount.test-d.ts new file mode 100644 index 00000000..a93ec482 --- /dev/null +++ b/tests/wave/mount.test-d.ts @@ -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); +});