// @strict: true type ExtendedService = { [K in keyof T]: T[K] & { __$daemonMode?: string; __$action?: string; }; }; type Service = { [K in keyof T]: T[K] & {id?: string}; }; export const createService = ( ServiceCtr: ExtendedService & Service ) => { Object.keys(ServiceCtr).forEach(key => { const method = (ServiceCtr)[key as keyof T]; const {__$daemonMode, __$action, id} = method; }) }