typescript/require-this-void
Require this: void on static class methods.
Targeted pattern scope
This rule targets static class methods whose function expression parameters do
not start with this: void.
What this rule reports
This rule reports static class methods that do not declare a this: void parameter.
Why this rule exists
An explicit this: void parameter documents that static methods do not depend
on a this context.
❌ Incorrect
class C {
static f() {}
}
✅ Correct
class C {
static f(this: void) {}
}
Behavior and migration notes
This rule reports only and does not provide an autofix.
Migration is adding this: void as the first static method parameter.
Options
This rule has no options.
Additional examples
class C {
static parse(this: C, value: string): C {
return new C();
}
}
// ❌ reported: first parameter is not `this: void`
class D {
static parse(this: void, value: string): D {
return new D();
}
}
// ✅ valid
ESLint flat config example
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/typescript/require-this-void": "error",
},
},
];
When not to use it
Disable this rule if your project does not enforce explicit static-method this typing.
Package documentation
Rule catalog ID: R130
Further reading
Adoption resources
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.