If you're looking for a fully type-safe, refactor-friendly alternative without relying on compiler transforms or macros, check out this new package:
@nameof/nameof
"someProperty"
instead of just string
)import nameof from "@nameof/nameof";
const obj = { someProperty: 123 } as const;
const key = nameof(obj, "someProperty");
// "someProperty", inferred type: "someProperty"