Skip to content

Commit 46edf5c

Browse files
committed
fix(types): support svg tags
Closes #27
1 parent 0d8ce78 commit 46edf5c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/index.test.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,12 @@ describe("twc", () => {
234234
>`py-2`;
235235
render(<Accordion type="single" collapsible></Accordion>);
236236
});
237+
238+
test("allows svg", () => {
239+
const Svg = twc.svg`text-xl`;
240+
render(<Svg data-testid="svg" />);
241+
const svg = screen.getByTestId("svg");
242+
expect(svg).toBeDefined();
243+
expect(svg.tagName).toBe("SVG");
244+
});
237245
});

src/index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ type Template<
4040
ResultProps<TComponent, TProps, TExtraProps, TCompose>
4141
>;
4242

43+
type ElementTagName = Exclude<
44+
keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap,
45+
"set"
46+
>;
47+
4348
type FirstLevelTemplate<
4449
TComponent extends React.ElementType,
4550
TCompose extends AbstractCompose,
@@ -57,7 +62,7 @@ type FirstLevelTemplate<
5762
type Twc<TCompose extends AbstractCompose> = (<T extends React.ElementType>(
5863
component: T,
5964
) => FirstLevelTemplate<T, TCompose, undefined>) & {
60-
[Key in keyof HTMLElementTagNameMap]: FirstLevelTemplate<
65+
[Key in ElementTagName]: FirstLevelTemplate<
6166
Key,
6267
TCompose,
6368
{ asChild?: boolean }

0 commit comments

Comments
 (0)