I am looking for a way to set a name string within a class and use it in the abstract class at the constructor level, meaning not within a function. I can't open up constructor because I am using typedi
.
Uncaught TypeError: this.name is not a function
abstract class Root {
abstract name(): string
notFoundError = new Error(`${this.name()} not found`)
}
class Use extends Root {
name = () => 'User'
}
const x = new Use()
throw x.notFoundError
I am not looking for this:
abstract class Root {
abstract name: string
notFoundError = () => new Error(`${this.name} not found`)
}
class Use extends Root {
name = 'User'
}
const x = new Use()
throw x.notFoundError()
Interested in notFoundError
not being a function.