Skip to content

Commit

Permalink
fix: narrow theme types for defaultProps and ComponentMultiStyleConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
TimKolberger committed Feb 6, 2021
1 parent 30d8a81 commit f3ba8dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/tricky-beers-smell.md
@@ -0,0 +1,7 @@
---
"@chakra-ui/react": patch
"@chakra-ui/theme": patch
---

Fixed an issue where the TypeScript types were too narrow for component
defaultProps and ComponentMultiStyleConfig
14 changes: 14 additions & 0 deletions packages/react/tests/extend-theme.test.tsx
Expand Up @@ -90,6 +90,20 @@ describe("extendTheme", () => {
expect(Object.keys(solidStyles).length).toBeGreaterThan(1)
})

it("should be able to extend a multipart component", () => {
const override: ThemeOverride = {
components: {
Textarea: {
defaultProps: {
focusBorderColor: "green.200",
},
},
},
}

extendTheme(override)
})

it("should pass typescript lint with random custom theme", () => {
const override = {
shadows: {
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/theme.types.ts
Expand Up @@ -33,7 +33,7 @@ export interface ColorHues {

export type ThemeDirection = "ltr" | "rtl"

interface ComponentDefaultProps {
interface ComponentDefaultProps extends Record<string, any> {
size?: string
variant?: string
colorScheme?: string
Expand All @@ -51,7 +51,7 @@ export interface ComponentSingleStyleConfig {
}

export interface ComponentMultiStyleConfig {
parts: string[]
parts?: string[]
baseStyle?: ThemeThunk<SystemStyleObjectRecord>
sizes?: SystemStyleObjectRecord
variants?: SystemStyleObjectRecord
Expand Down

0 comments on commit f3ba8dd

Please sign in to comment.