From 5583f19d7504a2539798236a042afc81beee313d Mon Sep 17 00:00:00 2001 From: VKotarac Date: Tue, 24 Jan 2023 11:42:01 +0100 Subject: [PATCH] add some type support --- src/classified.test.tsx | 10 ++++++---- src/classified.ts | 33 +++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/classified.test.tsx b/src/classified.test.tsx index 4eb24b0..eb52d98 100644 --- a/src/classified.test.tsx +++ b/src/classified.test.tsx @@ -23,7 +23,9 @@ test("should apply dynamic classNames", () => { }); test("should pass props to dynamic className creator", () => { - let Button = classified("button")([({ variant }: Props) => `btn-${variant}`]); + let Button = classified<"button", Props>("button")([ + ({ variant }) => `btn-${variant}`, + ]); render(); expect(screen.getByRole("button", { name: /hello/i }).className).toBe( "btn-primary" @@ -31,10 +33,10 @@ test("should pass props to dynamic className creator", () => { }); test("should combine both static and dynamic classNames", () => { - let Button = classified("button")([ + let Button = classified<"button", Props>("button")([ "btn", - ({ variant }: Props) => `btn-${variant}`, - ({ block }: Props) => block && "btn-block", + ({ variant }) => `btn-${variant}`, + ({ block }) => block && "btn-block", ]); render(