Try to understand the best way to overload methods in TypeScript classes and come with extends error while compiling.
There's an abstract class :
export abstract class Collection {
protected _collection: any;
public hydrate(key: number, item: Object): Collection;
public hydrate(key: any, item: any): Collection {
this._collection.set(key, item);
return this;
}
public size(): number {
return this._collection.size;
}
}
And the concrete class :
export class Tours extends Collection {
public constructor() {
super();
this._collection = new Map();
}
public hydrate(key: number, item: Tour) {
this._collection.set(key, item);
}
}
Compilation failed with an error on the types of the concrete class (number and Tour) that are not assignable to number and Object of the parent method.
As the Tour type is a custom type, don't know how implement correctly this classes scheme...
How to do that ?