Closed
Description
TypeScript Version: 4.1.2 (actually all versions 3.3.3 - 4.1.2)
Search Terms:
keyof declared object is not only string, keyof object type, keyof declared key, keyof
Code
type GenericObject = { [key: string]: any };
type GenericKeyType = keyof GenericObject;
Expected behavior:
GenericKeyType
should be of type string
Actual behavior:
GenericKeyType
is number | string
Playground Link:
https://www.typescriptlang.org/play?#code/C4TwDgpgBA4hB2EBOBLAxgeQEYCsJuCgF4oBvKAbQGsIQAuKAZ2FXgHMBdBgQ3hCgC+AbgBQI0JFgJk6ANK0AKuGgkaIAPYAzKYlSZc+YEKA
Related Issues:
Didn't find anything.