https://www.typescriptlang.org/play?#code/JYOwLgpg...
Не совсем понимаю почему return type у метода не валидирует корректно?
interface User {
username: string
password: string
id: number
}
type UserWithoutPassword = Omit<User, 'password'>
class AuthService {
async validateUser(username: User['username'], password: User['password']): Promise<UserWithoutPassword> {
const user: User = {
id: 1,
username: 'kek',
password: 'fdsfsd'
}
// I want to return all User interface fields exept password
// if (user?.password === password) {
// const { password, ...userInfo } = user
// return userInfo
// }
return user // why there is no error, if User !== UserWithoutPassword?
}
}