@empathyco/x-components
Version:
Empathy X Components
30 lines (19 loc) • 779 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [SubObject](./x-components.subobject.md)
## SubObject type
Extracts a sub-type with the properties of `SomeObject` that have the `TargetPropertyType` type.
**Signature:**
```typescript
export type SubObject<SomeObject, TargetPropertyType> = {
[Key in keyof SomeObject as SomeObject[Key] extends TargetPropertyType ? Key : never]: TargetPropertyType & SomeObject[Key];
};
```
## Example
```typescript
interface Person {
name: string,
surname: string,
age: number
}
type StringPersonProperties = SubObject<Person, string>; // { name: string; surname: string; };
```