interface ShelfItem { title: string; } /* There are lots of shelves in the library, and they can contain different types of objects. */ export default class Shelf<T extends ShelfItem> { private _items: Array<T> = new Array<T>(); add(item: T): void { this._items.push(item); } find(title: string): T { return this._items.filter(item => item.title === title)[0]; } getFirst(): T { return this._items[0]; } printTitles(): void { this._items.forEach(item => console.log(item.title)); } }