Skip to content

Commit

Permalink
fix: make custom properties optional in created types (#69) (#70)
Browse files Browse the repository at this point in the history
* fix: make custom properties optional in created types (#69)

* test: add custom property example to tests
  • Loading branch information
juice49 authored Nov 28, 2024
1 parent 4fc1c15 commit 672b575
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function render(parsed: Parsed): string {

if (Array.from(properties).length > 0) {
const propertyEntries = Array.from(properties)
.map((prop) => `'${prop}': string`)
.map((prop) => `'${prop}'?: string`)
.join(', ')
interfaceDefinition += ` style?: { ${propertyEntries} } & React.CSSProperties\n`
}
Expand Down
1 change: 1 addition & 0 deletions test/button.mist.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
button {
--highlightColor: rebeccapurple;
padding: 0.5rem 1rem;
border-radius: 0.25rem;
font-weight: bold;
Expand Down
1 change: 1 addition & 0 deletions test/mist.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
interface Mist_button extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
'data-variant'?: 'primary' | 'secondary'
style?: { '--highlightColor'?: string } & React.CSSProperties
}

interface Mist_div extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
Expand Down

0 comments on commit 672b575

Please sign in to comment.