score:0

Accepted answer

you have to tell TypeScript that the keyword name is a key of type ModuleType.

For that you have to write like this,


let name : keyof ModuleType = 'Whatever value it contains';

const formDataType = formData[name].type;

//  or

const formDataType = formData[<keyof ModuleType>name].type;



Related Query

More Query from same tag