I need to map interface properties to objects:
interface Activity {
id: string,
title: string,
body: string,
js
If you are okay with having it added during a compile time and you are using TypeScript >= 2.4.1, you can try the way proposed here.
Basically, you should add the ts-transformer-keys dependency, custom transformer, like a basic one and you'll be able to list the properties like this:
import { keys } from 'ts-transformer-keys';
interface Props {
id: string;
name: string;
age: number;
}
const keysOfProps = keys();
console.log(keysOfProps); // ['id', 'name', 'age']