Is there a way to generate an array containing the names of members of a specific type in an expression?
For example:
export type FileInfo = {
id: number
title ?: string
ext?: string|null
}
const fileinfo_fields = ["id","ext","title"];
I need to provide these field names as arguments to different methods for various types.
For instance:
const info = await api.get_info<FileInfo>(1234, fileinfo_fields);
This is necessary because managing multiple types with numerous fields can be error-prone.
Although type information is not accessible at runtime, I simply require a constant array that includes the member names.
Something along the lines of this, but I'm struggling to figure it out:
const fileinfo_fields = magic_extract_expression<FileInfo>; // ????
Do you know if achieving this is feasible in any way?