We have 2 interfaces: File and User. 1 File has 1 User.
We want to pick data from the user and the file.
interface DownloadFile {
id: string
name: string
user: User
createdAt: Date
}
interface User {
id: string
name: string
isEmailValidated: boolean
unsubscribe: boolean
email: string
}
type QueryResponse = {
file: Pick<DownloadFile, 'id' | 'name'> & {
user: Pick<DownloadFile['user'], 'id' | 'name' | 'email'>
}
}
This is working fine.
How can we prevent a typo in the nested object name (userTYPO) and get an error:
type QueryResponse = {
file: Pick<DownloadFile, 'id' | 'name'> & {
userTYPO: Pick<DownloadFile['user'], 'id' | 'name' | 'email'>
}
}