TypeScript Quiz_type aliases, union type, intersection type, enum
2022.03.29
#1
Person has name, age, address. Please select answers that has compile error.
type Info = {
name: string,
age: number
}type Person = Info & {
address: string
}
2.
interface Info {
name: string,
age: number
}type Address = {
address: string
}type Person = Info & Address;
3.
type Info = {
name: string,
age: number
}type Address = {
address: string
}type Person = Info & Address;
4.
interface Info {
name: string,
age: number
}interface Address {
address: string
}interface Person = Info & Address;
5.
interface Info {
name: string,
age: number
}interface Address {
address: string
}type Person = Info & Address;
6.
type Person = {
name: string,
age: number
}type Person = {
address: string
}
7.
type Info {
name: string,
age: number
}type Person extends Info {
address: string
}
#2
Company A uses 8 advertisement platform: Admob, Applovin, AdColony, IronSource, Inmobi, Kidoz, UnityAds, Vungle. Please make AdsPlatform that is a string type that can be one of the platforms.
#3
Does TypeScript advise to use Heterogeneous enums? (Y/N)
enum BooleanLikeHeterogeneousEnum {
No = 0,
Yes = "YES",
}
# 4
Reverse mapping can be applied for both numeric enums and string enums (T/F)
Answers.
- A4, 6, 7
2.
enum Platform {
Admob,
Applovin,
AdColony,
IronSource,
Inmobi,
Kidoz,
UnityAds,
Vungle
}
type AdsPlatform = keyof typeof Platform;
3. N
4. F