// initial types
interface Source {
id: string;
version: number; // discard
masterVariant: MasterVariant;
}
interface MasterVariant {
id: number; // discard
sku?: string;
}
// updated "simplified" types
interface Target {
id: string;
masterVariant: MasterVariantLight;
}
interface MasterVariantLight {
sku?: string;
}
To eliminate the version property, you can implement the following:
export class Convert {
public static toTarget(source: Source): Target {
const { version, ...result } = source;
return result;
}
}
If you are looking to remove masterVariant.id
using the same transformation method, do you see any possibilities?