TS1095
A 'set' accessor cannot have a return type annotation.
Broken Code ❌
export class Person {
private myName: string = 'unknown';
get name(): string {
return this.myName;
}
set name(newName: string): void {
this.myName = newName;
}
}Fixed Code ✔️
You have to remove the return type from the "set" accessor:
export class Person {
private myName: string = 'unknown';
get name(): string {
return this.myName;
}
set name(newName: string) {
this.myName = newName;
}
}