Skip to content

Commit

Permalink
fix(polymorphic): merge default props (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Jun 22, 2021
1 parent f3195bb commit 623694f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/__snapshots__/styl.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ exports[`styl props polymorphic > TouchableWithoutFeedback 1`] = `
</Text>
`;

exports[`styl props polymorphic merge props 1`] = `
<Text
style={
Array [
Object {
"color": "blue",
},
Object {},
]
}
>
Text
</Text>
`;

exports[`styl props renders custom props 1`] = `
<Text
color="blue"
Expand Down
10 changes: 10 additions & 0 deletions lib/styl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ describe('styl', () => {
const json = render.toJSON()
expect(json).toMatchSnapshot()
})

it('polymorphic merge props', () => {
const Title = styl(Text)<{ color?: string }>({ color: 'blue' })

const render = renderer.create(<Title>Text</Title>)

// Snapshot
const json = render.toJSON()
expect(json).toMatchSnapshot()
})
})

describe('theme/provider', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/styl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ interface Polymorphic<
> {
<As extends ComponentType<any> = IntrinsicElement>(
props: As extends JSXElementConstructor<infer AsProps>
? OwnProps & { ref?: As } & { as?: As } & AsProps
? DefaultProps & OwnProps & { ref?: As } & { as?: As } & AsProps
: never
): ReactElement | null
}
Expand Down

0 comments on commit 623694f

Please sign in to comment.