TS6138

error TS6138: Property ‘lastName‘ is declared but its value is never read.

Broken Code ❌

User.ts
1
2
3
4
5
6
7
8
class User {
constructor(private firstName: string, private lastName: string) {
}

get fullName() {
return this.firstName;
}
}

Fixed Code ✔️

Simply make use of the lastName property:

User.ts
1
2
3
4
5
6
7
8
class User {
constructor(private firstName: string, private lastName: string) {
}

get fullName() {
return `${this.firstName} ${this.lastName}`;
}
}