You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
390 B
21 lines
390 B
let person: { name: string; age: number; sayHi(): void; greet(name: string) : void } = {
|
|
name: 'Ken',
|
|
age: 20,
|
|
sayHi() {},
|
|
greet(name) {}
|
|
}
|
|
|
|
|
|
let person2: {
|
|
name: string
|
|
age: number
|
|
// sayHi: () => void
|
|
// 也可是使用箭头函数
|
|
sayHi: () => void
|
|
greet(name: string): void
|
|
} = {
|
|
name: 'Ken',
|
|
age: 20,
|
|
sayHi() {},
|
|
greet(name) {}
|
|
}
|