I have an object in Typescript that I am destructuring in order to extract a partial object. However, it fails my linter check:
async someFunction(username: string): Promise<UserDTO> {
const userEntity = await getUserByUsernameAsync(username);
if (userEntity ) {
const { password, ...result } = userEntity ;
return result;
}
return null;
}
As you can see, the above code grabs an object and strips out some parts of the object that we don't want to return, and returns the rest of the object.
However, the linter gives a warning:
warning 'password' is assigned a value but never used @typescript-eslint/no-unused-vars
The object destructuring is assigning passport to a value and result to another object value and passport is the one that isn't being used. How do I fix this issue in order to pass the linter?