export interface Fields { '@timestamp' ? : number ; } export class Entity < TFields extends Fields > { constructor ( public readonly fields ) { this . fields = fields ; } defaults ( defaults ) { Object . keys ( defaults ) . forEach ( ( key ) => { const fieldName = key as any ; if ( ! ( fieldName in this . fields ) ) { this . fields [ fieldName ] = defaults [ fieldName ] as any ; } } ) ; return this ; } }