Acknowledgement
Comment
type T1 = { [x: string]: unknown };
// ^? type T1 = { [x: string]: unknown; }
type K1 = keyof T1;
// ^? type K1 = string | number
type T2 = Record<string, unknown>;
// ^? type T2 = { [x: string]: unknown; }
type K2 = keyof T2;
// ^? type K2 = string
Expected: K2 should have also been string | number because:
-
We can access number from T2:
type AccessT2 = T2[number]; // ✅ Allowed
// ^? type AccessT2 = unknown
-
T2 is the same as T1 so their keyof behavior should also be same.