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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to have two themes at the same time with Typescript? #418

Open
eranimo opened this issue Apr 18, 2024 · 0 comments
Open

Is it possible to have two themes at the same time with Typescript? #418

eranimo opened this issue Apr 18, 2024 · 0 comments

Comments

@eranimo
Copy link

eranimo commented Apr 18, 2024

I am trying to, for scope reasons, add a new set of components to an app that has a new theme. This new theme has a different type signature than the old theme. The old theme is set up using the Typescript docs for styled-components and the components using it import from styled-components, not xstyled.

How can I go about doing this? I tried re-exporting the x and styled export but it looks like the X type still refers to the DefaultTheme type for some reason.

import { system, StyleGenerator, SystemProps } from '@xstyled/system';
import { createCss } from '@xstyled/styled-components';
import * as styledComponents from 'styled-components';

import { ITheme } from './theme'; // new theme type

const module = createCss<StyleGenerator<SystemProps<ITheme>>>(system);

export const css = module.css;
export const styled = module.styled;
export const x = module.x as any;

Essentially, instead of overriding the types using a declaration file I would like to re-export them with the correct theme and create components using that new component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant