Within my Nestjs application, there is an entity class structured like this:
@ObjectType()
export class Companies {
@Field(() => Int)
@PrimaryGeneratedColumn({ type: 'int', name: 'id' })
public id: number;
@Field()
@Column('enum', {
name: 'status',
enum: ['trial', 'live', 'disabled'],
default: () => "'trial'"
})
public status: 'trial' | 'live' | 'disabled';
@Field()
@Column('tinyint', {
name: 'status_inbound',
width: 1,
})
public statusInbound: boolean;
I am interested in creating a new class that will exclusively inherit the boolean properties (status_inbound) from the existing company class.
CompaniesSettings {
@Field()
@Column('tinyint', {
name: 'status_inbound',
width: 1,
})
public statusInbound: boolean;
}
If additional boolean properties are later added to the Companies class, TypeScript should automatically acknowledge and permit these properties within the CompaniesSettings class. If selective inheritance of only boolean properties when defining a new class is not feasible, using types are also a viable solution.
type CompaniesSettings = Pick<Companies,'statusInbound'>