Types for a destructured object
I had run into this issue before. How do you write types for a destructrued object eg:
login ({ username, password, remember })
In Javascript that is fairly easy to do, cause you have to do nothing, but the problem was writing the types for this. I thought of the obvious solution:
login({ username: string, password: string, remember: boolean})
Well, that is a wrong way to do it. The correct way to do it would be:
login: ({ username, password, remember }: { username: string, password: string, remember: boolean})
Hope this one helps someone break from the chains of ts-ignore
and any
.
The end!