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

prop does not work with optional keys #431

Open
jerelmiller opened this issue Feb 26, 2019 · 1 comment
Open

prop does not work with optional keys #431

jerelmiller opened this issue Feb 26, 2019 · 1 comment

Comments

@jerelmiller
Copy link

Hey there 👋

I have been unable to use prop with optional keys. I tend to use prop a lot with something like styled-components which gives me a nice shorthand for accessing the interpolated values. Here is an example of a pattern I use quite a bit.

interface Props {
  width?: string
}

const Button = styled.button<Props>`
  width: ${prop('width')}
`

Button.defaultProps = {
  width: 'auto'
}

I however get an error similar to the following:

Property 'gap' is optional in type ... but required in type 'Record<"gap", string | undefined>

Is this something that is possible? I really like the prop shorthand and tend to use it all over the place. Any help would be appreciated. Thank you!

@oleksandr-hyriavets
Copy link

Stuck with the same issue. Is there any workaround to fix that?

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

2 participants