Skip to content
Advertisement

Tag: spread-syntax

How to conditionally add a key to an object?

Consider these types: I want to convert an object of type A into B by overwriting some keys and adding keys conditionally depending on whether the original object has them: TypeScript throws this error: Why is it inferring b in this way? Is there a way to work around it? Answer It’s a combination of two minor design limitations and

Advertisement