How can I create an expression that contains an array of member names of that given type?
Example:
export type FileInfo = {
id: number
title ?: string
ext?: string|null
}
const fileinfo_fields = ["id","ext","title"];
I need to pass the field names to various methods for many different types.
Example:
const info = await api.get_info<FileInfo>(1234, fileinfo_fields);
I need this because there are too many types with too many fields, and I'm affraid of making mistakes.
I understand that type information is not available at runtime, but all I need is a constant array that contains the field names.
Something like this, just I can't figure out:
const fileinfo_fields = magic_extract_expression<FileInfo>; // ????
Is it possible somehow?