I am currently facing an issue with a field in my type that contains a constant string literal. My goal is to be able to reference both the type and field by name so that I can utilize this string literal throughout my code. Here is an example:
export type MyType = {
action?: 'TestAction';
arg0: true,
};
/////
let input: any = {
action: 'XYZ',
};
if (input.action === MyType.action) { // This obviously does not work
// TODO: perform TestAction
}
Is there a way to achieve this without having to separate 'TestAction'
into its own const definition?