Here is my code snippet:
interface ICar {
brand():string;
brand(brand:string):void;
}
class Car implements ICar {
private _brand: string;
get brand():string {
return this._brand;
}
set brand(brand:string) {
this._brand = brand;
}
}
var car = new Car();
car.brand = 'Toyota';
Upon closer inspection, it seems like the interface is properly implemented. However, when trying to compile with tsc, an error is thrown:
C:\Users\User>tsc interfaces.ts --target "es5"
interfaces.ts(11,7): error TS2420: Class 'Car' incorrectly implements interface 'ICar'.
Types of property 'brand' are incompatible.
Type 'string' is not assignable to type '{ (): string; (brand: string): void; }'.