Open strager opened 3 months ago
In a TypeScript type, keyof T[] is the same as number (I think). The user likely meant (keyof T)[]. We should emit a warning, telling them to write either number or add parentheses.
keyof T[]
number
(keyof T)[]
Inspired by this article: https://www.totaltypescript.com/array-types-in-typescript
Using keyof with T[] can lead to unexpected results. const result: keyof Person[] = ["id", "name"];
Using keyof with T[] can lead to unexpected results.
const result: keyof Person[] = ["id", "name"];
In a TypeScript type,
keyof T[]
is the same asnumber
(I think). The user likely meant(keyof T)[]
. We should emit a warning, telling them to write eithernumber
or add parentheses.Inspired by this article: https://www.totaltypescript.com/array-types-in-typescript