Skip to content

Instantly share code, notes, and snippets.

@fredriccliver
Created September 18, 2020 03:41
Show Gist options
  • Save fredriccliver/e6cdec5fff401bf8de295b6ef545b842 to your computer and use it in GitHub Desktop.
Save fredriccliver/e6cdec5fff401bf8de295b6ef545b842 to your computer and use it in GitHub Desktop.
const origData = [
{
uid:123123,
displayName: "user1",
email: null,
emailVerified: false,
isAnonymous: false,
photoURL: "http://gooooooo.com/123123jiji",
nestedData: {
admin: false,
address: "123 Baker st, London, UK",
age: null,
gender: "neutral"
}
},
{
uid:45345345,
displayName: "user2",
email: null,
emailVerified: false,
photoURL: "http://gooooooo.com/123123jiji",
accountType: "google",
createdTime: 4234335542,
nestedData: {}
},
{
uid:87897,
displayName: "user34234234",
email: "[email protected]",
emailVerified: true,
isAnonymous: true,
photoURL: "http://gooooooo.com/123123jiji",
accountType: "google",
createdTime: 234252555,
nestedData: {
admin: false,
address: null,
age: 34,
gender: "male"
}
},
]
export interface AdminUser {
uid?: string
displayName?: string
email?: string
emailVerified?: boolean
isAnonymous?: boolean
photoURL?: string
}
let adminList = origData.map((data) => {
return data as unknown as AdminUser
})
// my expecting after force casting
adminList = [
{
uid:123123,
displayName: "user1",
email: null,
emailVerified: false,
isAnonymous: false,
photoURL: "http://gooooooo.com/123123jiji",
},
{
uid:45345345,
displayName: "user2",
email: null,
emailVerified: false,
isAnonymous: null,
photoURL: "http://gooooooo.com/123123jiji",
},
{
uid:87897,
displayName: "user34234234",
email: "[email protected]",
emailVerified: true,
isAnonymous: true,
photoURL: "http://gooooooo.com/123123jiji",
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment