Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: narrow theme types for defaultProps and ComponentMultiStyleConfig #3300

Merged
merged 2 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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