1

I am trying to create tokens with emotion but it is not working, I believe because of the typescript, because in javascript files it works. Does anyone know how to solve?

My theme:

import '@emotion/react';

export const palette = {
  common: {
    black: '000',
    white: 'fff'
  }

my component:

    import styled from '@emotion/styled';
    
    import { theme } from '../../utils/theme';    
         

      export const button = styled.button`
           background: ${({ theme }) => theme.pallete.common.black};
        `;

error:

Property 'pallete' does not exist on type 'object'
1
  • You are exporting const palette but you are importing theme and then doing nothing with theme. Commented Mar 22, 2021 at 15:35

2 Answers 2

1

You seem to have a typo

Property 'pallete' does not exist on type 'object'

while the name is palette

Try fixing the name

Sign up to request clarification or add additional context in comments.

1 Comment

hi, it was a typo here, the code is correct and the error continues
0

Hi you can type your component like this.


interface Pallete {
 common: {
   black: '#000'
 }
}
export const button = styled.button<{ pallete: Pallete }>`
  background: ${({ pallete }) => pallete.common.black};
`;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.