-
Notifications
You must be signed in to change notification settings - Fork 25
Open
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.
Metadata
Metadata
Assignees
Labels
No labels