noEmptyTypeParameters
Ce contenu n’est pas encore disponible dans votre langue.
Summary
Section titled “Summary”- Rule available since:
v1.5.0
- Diagnostic Category:
lint/complexity/noEmptyTypeParameters
- This rule is recommended, which means is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is warning.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "complexity": { "noEmptyTypeParameters": "error" } } }}
Description
Section titled “Description”Disallow empty type parameters in type aliases and interfaces.
TypeScript permits the use of empty type parameter lists in type alias and interface declarations; however, this practice is generally discouraged. Allowing empty type parameter lists can lead to unclear or ambiguous code, where the intention of the generic type is not self-evident. This rule disallows empty type parameter lists in type alias and interface declarations.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”interface Foo<> {}
code-block.ts:1:14 lint/complexity/noEmptyTypeParameters ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Using an empty type parameter list is confusing.
> 1 │ interface Foo<> {}
│ ^^
2 │
ℹ Remove the empty type parameter list or add a type parameter.
type Bar<> = {};
code-block.ts:1:9 lint/complexity/noEmptyTypeParameters ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Using an empty type parameter list is confusing.
> 1 │ type Bar<> = {};
│ ^^
2 │
ℹ Remove the empty type parameter list or add a type parameter.
interface Foo {}
type Foo<T> = { bar: T;}
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.