8000 TypeScript Error When Using CSS Variables in Props · Issue #1075 · facebook/stylex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
TypeScript Error When Using CSS Variables in Props #1075
Open
@michaltarasiuk

Description

@michaltarasiuk

Describe the issue

I'm trying to pass styles as props in TypeScript, but I'm getting an error when I use a CSS variable. The error says that the type 'Color<...>' can't be assigned to 'Readonly<string | null | undefined>' in the style prop.

Expected behavior

Extend the type 'Readonly<string | null | undefined>' to include a CSS variable

Steps to reproduce

function Parent() {
  return <Child style={styles.base} />;
}

function Child({style}: {style: stylex.StyleXStyles}) {
  return <div {...stylex.props(style)} />;
}

const styles = stylex.create({
  base: {
    backgroundColor: baseColors.background,
  },
});

// tokens.stylex.ts
const baseColors = stylex.defineVars({
  background: stylex.types.color('#000000'),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0