This question is similar, but a bit different from Typescript 2.8: Remove properties in one type from another
I would like to create a function that takes a type, and returns a new type that doesn't include properties that are of type Array or are other complex (nested) objects.
I'm assuming conditional types are the best (only?) way to handle this? How can this be accomplished?
You can create a conditional type that only preserved primitive types (excludes arrays and other objects) using conditional types (to pick out the keys) and
PickThe actual function implementation should be pretty simple, just iterate the object properties and exclude
objectEdit Added correct handling for optional fields.