I have a JavaScript helper function which allows to remove a property of an object :
removeProp(obj, prop) {
const { [prop]: _, ...result } = obj;
return result;
}
TypeScript version :
removeProp(obj: Object, prop: string): Object {
// tslint:disable-next-line: no-shadowed-variable
const { [prop]: _, ...result } = obj;
return result;
}
1- I have a lint error : type 'Object' has no index signature corresponding to type 'string' tslint in [prop].
2- How i can initialize result variable with the right type if obj is a generic (takes all properties of the generic type - the removed property) ?