propEq type doesn't account for optional properties
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start with the failing test mentioned in the issue and inspect the TypeScript definitions for the curried propEq entry point. Compare its behavior with the three-argument form and existing tests. Done means the optional-property example type-checks without regressing the existing propEq cases.
Written by the indexing model from the issue text.
Description
type DemoType = {
optionalProp?: string
}
const filteredList = propEq('Yes', 'optionalProp')({ optionalProp: 'Yes' } as DemoType)
This produces this error:
Argument of type 'DemoType' is not assignable to parameter of type 'Record<"optionalProp", string>'.
Types of property 'optionalProp' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
I feel like this should work just fine? The code runs as expected, just produces a the error.
it doesn't error if you pass all parameters at the same time rather than using the curried functions. I'm really not sure why.
propEq('Yes', 'optionalProp', { optionalProp: 'Yes' } as DemoType)
I've forked the project and written a failing test, but sadly I'm not proficient enough at typescript to write something that does any type guarding but allows my use case.
- Dominant language
- TypeScript
- Stars
- 31
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ramda/types
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
`intersection` should return an array of the intersection of the types of each array's elementsOpen
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug:new
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
callstackincubator/simlock#350 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
openwatersio/maritime-zones#33 ·
Maintainers usually reply within 1 day
-
Booking email verification fails for plus aliases with impersonation protection enabledPossibly taken @kankadev claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
calcom/cal.diy#30293 · 1 comment ·
Maintainers usually reply within 5 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AOSSIE-Org/DebateAI#611 ·
Maintainers usually reply within 3 days