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

How to make the Typescript Intelisense to Work based on theme props values? #1909

Open
ebellumat opened this issue Apr 3, 2021 · 1 comment
Labels

Comments

@ebellumat
Copy link

ebellumat commented Apr 3, 2021

Hello guys, first, thank you for this great work.

I have a simple question, how to make the Intelisense of configured props of themes on Vscode?

Heres my component.

import styled from 'styled-components/native';
import { color, space, SpaceProps, ColorProps } from "styled-system";

export type BoxProps = SpaceProps &
  ColorProps;

export const Box = styled.View<BoxProps>`
  ${color}
  ${space}
`

My small theme

import * as tokens from '../tokens';

export const theme = {
    colors: {
        red: tokens.primary,
        green: tokens.secondary
    }
} as const;

Even with this, this color props not appear when i use my component to complete. I want to make my job easier.

image

What i'm doing wrong?

@shawngustaw
Copy link

I believe you can accomplish this by doing the following:

type ThemeType = typeof theme

export type BoxProps = SpaceProps<ThemeType> &
  ColorProps<ThemeType>;

export const Box = styled.View<BoxProps>`
  ${color}
  ${space}
`

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

No branches or pull requests

2 participants