I'm encountering an issue with my Typescript code where I am destructuring an object to extract a partial object, but it's failing the linter check. Here is the problematic code snippet:
async someFunction(username: string): Promise<UserDTO> {
const userEntity = await getUserByUsernameAsync(username);
if (userEntity ) {
const { password, ...result } = userEntity ;
return result;
}
return null;
}
The code above removes certain parts of an object and returns the remaining data. However, when running the linter, I receive this warning:
warning 'password' is assigned a value but never used @typescript-eslint/no-unused-vars
The issue lies in assigning password
to a variable that is not being utilized. How can I rectify this problem to satisfy the linter?