Skip to content

typescript/no-this-alias Correctness

This rule is turned on by default.

What it does

Disallow unnecessary constraints on generic types.

Why is this bad?

Generic type parameters (<T>) in TypeScript may be "constrained" with an extends keyword. When no extends is provided, type parameters default a constraint to unknown. It is therefore redundant to extend from any or unknown.

the rule doesn't allow const {allowedName} = this this is to keep 1:1 with eslint implementation sampe with obj.<allowedName> = this



## How to use

To **enable** this rule in the CLI or using the config file, you can use:

::: code-group

```bash [CLI]
oxlint --deny typescript/no-this-alias
Config (.oxlintrc.json)
json
{
  "rules": {
    "typescript/no-this-alias": "error"
  }
}

:::

References

Released under the MIT License.