Skip to content

Commit

Permalink
Merge pull request #3300 from chakra-ui/fix/theme-types-default-props
Browse files Browse the repository at this point in the history
fix: narrow theme types for defaultProps and ComponentMultiStyleConfig
  • Loading branch information
segunadebayo committed Feb 6, 2021
2 parents 30d8a81 + 83a3f78 commit 02ca2b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/tricky-beers-smell.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
- name: Build CRA templates
run: yarn build:templates ../cra-templates

- name: Lint types and code
run: yarn lint

- name: Run tests
run: yarn test

Expand Down
14 changes: 14 additions & 0 deletions packages/react/tests/extend-theme.test.tsx
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

1 comment on commit 02ca2b7

@vercel
Copy link

@vercel vercel bot commented on 02ca2b7 Feb 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.