Created
September 18, 2020 03:41
-
-
Save fredriccliver/e6cdec5fff401bf8de295b6ef545b842 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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