0
以下是type alias部分中官方文檔的示例。類型別名中的打字稿類型交集
type LinkedList<T> = T & { next: LinkedList<T> };
interface Person {
name: string;
}
var people: LinkedList<Person>;
var s = people.name;
//var s = people.next.name;
//var s = people.next.next.name;
//var s = people.next.next.next.name;
當我嘗試這個例子中生成以下錯誤:
TypeError: Cannot read property 'name' of undefined
人來說是一個鏈表類型。如何正確填寫人員鏈接列表?