Skip to content

Commit 0383b5d

Browse files
committed
fix: fix className type
1 parent a5bd67b commit 0383b5d

File tree

4 files changed

+224
-3
lines changed

4 files changed

+224
-3
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"@ampproject/filesize": "^4.3.0",
41+
"@radix-ui/react-accordion": "^1.1.2",
4142
"@swc/core": "^1.3.101",
4243
"@testing-library/react": "^14.1.2",
4344
"@types/react": "^18.2.42",

pnpm-lock.yaml

+214-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.test.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Button as AriaButton,
99
ButtonProps as AriaButtonProps,
1010
} from "react-aria-components";
11+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
1112

1213
describe("twc", () => {
1314
beforeEach(cleanup);
@@ -226,4 +227,11 @@ describe("twc", () => {
226227
expect(button.classList.contains("bg-gray-700")).toBe(true);
227228
expect(button.classList.contains("opacity-35")).toBe(true);
228229
});
230+
231+
test("props are correctly typed", () => {
232+
const Accordion = twc(AccordionPrimitive.Root)<
233+
React.ComponentProps<typeof AccordionPrimitive.Root>
234+
>`py-2`;
235+
render(<Accordion type="single" collapsible></Accordion>);
236+
});
229237
});

src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function filterProps(
100100

101101
type Attributes = Record<string, any> | ((props: any) => Record<string, any>);
102102

103-
export const createTwc = <TCompose extends AbstractCompose>(
103+
export const createTwc = <TCompose extends AbstractCompose = typeof clsx>(
104104
config: Config<TCompose> = {},
105105
) => {
106106
const compose = config.compose || clsx;

0 commit comments

Comments
 (0)