typed-typings / npm-ramda

TypeScript's type definitions for Ramda
MIT License
384 stars 64 forks source link

`prop` does not work with optional keys #431

Open jerelmiller opened 5 years ago

jerelmiller commented 5 years ago

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 commented 4 years ago

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