TypeScript ရှိ ရှုပ်ထွေးသော Object များ
Object များသည် ၎င်းတို့၏ အတွင်း၌ မည်သည့် အနက်ရှိုင်းအဆင့်၏ တည်ဆောက်ပုံမဆို ရှိနိုင်ပြီး ထိုတည်ဆောက်ပုံကို Object ကို ကြေငြာသည့်အခါတွင် သို့မဟုတ် interface တွင် ဖော်ပြနိုင်သည်။
ဥပမာအနေဖြင့် အောက်ပါအတိုင်း user တစ်ဦးကို ဖော်ပြသော interface တစ်ခု ဖန်တီးကြည့်ပါ။
typescriptinterface User {
name: string,
age: number,
parents: {
mother: string,
father: string
}
}
ဤ interface ကို အကောင်အထည်ဖော်သည့် Object တစ်ခု ဖန်တီးကြည့်ပါ။
typescriptlet user: User = {
name: 'john',
age: 30,
parents: {
mother: 'jane',
father: 'eric'
}
}
Задание 1
အောက်ပါ Object ကို ပေးထားသည်။
typescriptlet event = {
name: 'my new event',
time: {
start: '2025-11-01',
finish: '2025-12-31'
}
};
ဤ Object ၏ တည်ဆောက်ပုံကို ဖော်ပြသည့် interface တစ်ခု ဖန်တီးပါ။
Задание 2
အောက်ပါ Object ကို ပေးထားသည်။
typescriptlet employee {
name: 'andrew',
potision: {
name: 'programmer'
salary: 1000,
}
addr: {
country: 'belarus',
city: 'minsk'
}
};
ဤ Object ၏ တည်ဆောက်ပုံကို ဖော်ပြသည့် interface တစ်ခု ဖန်တီးပါ။