I want to retrieve the keys from a defined object in Typescript. You can find the playground here with information on actual and expected output.
// I want users to define a variable (or const) of type A
// and then extract the keys from A
type A = {
[key: string]: 123,
}
const aTyped: A = {
myKey: 123,
} as const;
type ExtractKeys<T> = keyof T;
type Keys = ExtractKeys<typeof aTyped>; // expected: Keys = 'myKey'
// actual value: string | number :(