I try to get properties name from generic interface in TypeScript, I have tried to create object and use keys property from Object, but I can do it. Can anyone helps me?
const getPropertiesByType = <T>(): string[] => {
const emptyInstance: T = ??
return Object.keys(emptyInstance)
}
Tdoes not affect return type() => {const emptyInstance = ???; return Object.keys(emptyInstance);}so there's no input to that function and thus nothing foremptyInstanceto be initialized with. You can maybe add build steps to transform your TS to JS in a way that adds relevant type info; see the answers to the linked questions for more information.