Skip to content

accessorThisRecursion

Reports recursive access to this within getters and setters.

✅ This rule is included in the ts logical and logicalStrict presets.

Accessing this.propertyName inside a getter or setter for propertyName triggers that same accessor again, causing infinite recursion and a stack overflow error at runtime.

class
class Example
Example
{
get
Example.name: any
name
() {
return this.
Example.name: any
name
;
}
set
Example.value: number
value
(
newValue: number
newValue
: number) {
this.
Example.value: number
value
=
newValue: number
newValue
;
}
}
const
const obj: {
readonly count: any;
}
obj
= {
get
count: any
count
() {
return this.
count: any
count
;
},
};

This rule is not configurable.

There’s no reason to disable this rule, as recursive accessor access always causes a runtime error.

Made with ❤️‍🔥 around the world by the Flint team and contributors.