diff --git a/docs/no-unnecessary-generics.md b/docs/no-unnecessary-generics.md index 8a920309..6507e8ed 100644 --- a/docs/no-unnecessary-generics.md +++ b/docs/no-unnecessary-generics.md @@ -46,6 +46,13 @@ function clear(array: any[]): void; --- +`getMeAT(): T`: +If a type parameter does not appear in the types of any parameters, you don't really have a generic function, you just have a disguised type assertion. +Prefer to use a real type assertion, e.g. `getMeAT() as number`. +Example where a type parameter is acceptable: `function id(value: T): T;`. +Example where it is not acceptable: `function parseJson(json: string): T;`. +Exception: `new Map()` is OK. + **Bad**: ```ts