noEmptyTypeParameters
¥Summary
-
规则生效日期:
v1.5.0¥Rule available since:
v1.5.0 -
诊断类别:
lint/complexity/noEmptyTypeParameters¥Diagnostic Category:
lint/complexity/noEmptyTypeParameters -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
¥How to configure
{ "linter": { "rules": { "complexity": { "noEmptyTypeParameters": "error" } } }}¥Description
禁止类型别名和接口中的空类型参数。
¥Disallow empty type parameters in type aliases and interfaces.
TypeScript 允许在类型别名和接口声明中使用空类型参数列表;但是,通常不鼓励这种做法。允许空类型参数列表可能会导致代码不明确或模棱两可,其中泛型类型的意图不言而喻。此规则不允许在类型别名和接口声明中使用空的类型参数列表。
¥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
¥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.
¥Valid
interface Foo {}type Foo<T> = { bar: T;}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号