Optional Properties
interface User {
username: string
email: string
}
// หรือ
type User = {
username: string
email: string
}
let a: User = {
username: "foo",
email: "[email protected]",
}
let b: User = { // ❌ Type Error : ไม่ได้กำหนด Property 'email'
username: "bar"
}
Last updated