question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

extendTheme's return type is any

See original GitHub issue

🐛 Bug report

Provide a brief description of the bug here

It seems that at some point extendTheme’s return type became any.

💥 Steps to reproduce

Clear and concise reproduction steps are important for us to be able to triage your issue in a timely manner

  1. Attempt to extend theme
const colors = {
brand: {
  100: "#ffffff",
  200: "#ededed"
}
};

const extendedTheme = extendTheme({ colors });
  1. observe type of extendedTheme variable in editor is any

💻 Link to reproduction

Minimial repro

🧐 Expected behavior

Tell us what you expect to happen.

A return type that reflects the extended theme.

This is the code that was working at some point.

import { extendTheme, useTheme } from '@chakra-ui/react';

export const theme = extendTheme(overrides, baseTheme);
export type AppTheme = typeof theme;

const theme = useTheme<AppTheme>();

🌍 System information

Software Version(s)
Chakra UI >1.0.4

📝 Additional information

image

I’m not sure if something changed with the api and I just missed it. Let me know if I can help in any other way.

Thanks for all of the hard work and the great library!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
TimKolbergercommented, Jan 22, 2021

The introduction of an arbitrary base theme lead to the return type any.

Next step would be to define a generic ChakraTheme type and not to derive the Theme type from the default theme. I am thinking of something like

type ChakraTheme = ToBeDefined

function extendTheme(override: DeepPartial<ChakraTheme>, baseTheme: ChakraTheme): ChakraTheme
0reactions
Slmiicommented, Jan 21, 2021

Looks like 1.0.4 is working fine

Yes, can confirm. Hope it will return to the latest version as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

Terms - ExtendThemes
Refund Policy: We offer refunds to any unsatisfied customer up to fourteen (14) days after the purchase was made. If you would like...
Read more >
CSS theme variables - Customization - Material UI - MUI
extendTheme() returns a theme for CssVarsProvider . Color schemes. The major difference from the default approach is in palette customization. With the ...
Read more >
Customize Theme - Chakra UI
Customizing theme tokens​​ To extend or override a token in the default theme, import the extendTheme function and add the keys you'd like...
Read more >
Customizing Theme - NativeBase
The Theme is one of the core elements of NativeBase. You can customize NativeBase's theme as per your liking. NativeBase theme is a...
Read more >
Customize Theme - Chakra UI
In some scenarios, you might need to customize the theme tokens to match your ... import the extendTheme function and add the keys...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found