I am in a state of confusion on how I would go about type-checking this variable, but I am not able to do it.
What I understand is that this is an object which contains fields, but these fields are written in a obscure way.
The object is called userApproval
Here is the object when I output it to console.
{
l8s.restart_trigger: true, l8s.system_scale: true, manager.cleanup: true,
manager.extend: true
}
Now this is the type I am attempting to type to,
export type UserApproval = {
MANAGER_CLEANUP: boolean;
MANAGER_EXTEND: boolean;
L8S_SYSTEM_SCALE: boolean;
L8S_RESTART_TRIGGER: boolean;
};
Is this correct
Advertisement
Answer
I think the keys of your object are example.test so based on that try this types.
type ApprovalTypes = {
'l8s.restart_trigger': boolean;
'l8s.system_scale': boolean;
'manager.cleanup': boolean;
'manager.extend': boolean;
}
const data:ApprovalTypes = {
'l8s.restart_trigger': true,
'l8s.system_scale': true,
'manager.cleanup': true,
'manager.extend': true
}