Styled-system: Variant example in docs fails in Typescript.

Created on 14 Aug 2019  路  3Comments  路  Source: styled-system/styled-system

On page https://styled-system.com/variants

This example:

const Button = styled('button')(
  variant({
    scale: 'buttons',
    variants: {
      primary: {
        color: 'white',
        bg: 'primary',
      },
      secondary: {
        color: 'white',
        bg: 'secondary',
      },
    },
  })
)

get a typescript error

Argument of type '{ scale: string; variants: { primary: { color: string; bg: string; }; secondary: { color: string; bg: string; }; }; }' is not assignable to parameter of type 'VariantArgs'.
  Object literal may only specify known properties, and 'variants' does not exist in type 'VariantArgs'.

I basically can't get themeable variants to work when using typescript.

I'm using
"@types/styled-system": "^5.0.1",
"styled-system": "^5.1.0",

Most helpful comment

Maybe I will try my first contribution to open source and do a pull request

All 3 comments

I think whoever maintains @types/styled-system will need to update the types for the new API

Maybe I will try my first contribution to open source and do a pull request

I think this can be closed, @types/styled-system 5.1.1 updated the VariantArgs interface.

Thanks @benjamingeorge!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmarkowitz picture wmarkowitz  路  4Comments

smolak picture smolak  路  4Comments

duro picture duro  路  5Comments

philholden picture philholden  路  5Comments

vdesdoigts picture vdesdoigts  路  3Comments