Closed
Description
Put simply, I'd like a variant of keyof which produces the keys at runtime. E.g.,
interface Foo {
prop1: number;
prop2: string;
}
const x = keyof Foo;
In this case x
should be ["prop1", "prop2"]
.
I've seen a few cases where people have tried to use keyof
in somewhat-similar fashions, but they all wanted the actual keys present in the object at runtime. I however very explicitly want to ignore any properties present in any hypothetical runtime Foo objects that are not present in the interface.
Should permit generic parameters as the type.
Activity