-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Out of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScriptAn idea for TypeScript
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.
krryan, levenleven, alexturek, kylecordes, r-k-b and 31 morefrederickfogerty
Metadata
Metadata
Assignees
Labels
Out of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScriptAn idea for TypeScript