Clean Code: Comments
Use comments sparingly and only when necessary. Good code should be mostly self-explanatory.
Let's explore some examples in TypeScript to help you grasp the concept:
/// Bad
/**
* Get the user's info
* @param id
* @returns user info
*/
function getUserInfo(id: number) {
// fetch the user
return fetch(`/api/users/${id}`).then((response) => response.json());
}
// Good
function fetchUserInfo(userId: number) {
return fetch(`/api/users/${userId}`).then((response) => response.json());
}