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.
JavaScript
x
5
1
{
2
l8s.restart_trigger: true, l8s.system_scale: true, manager.cleanup: true,
3
manager.extend: true
4
}
5
Now this is the type I am attempting to type to,
JavaScript
1
7
1
export type UserApproval = {
2
MANAGER_CLEANUP: boolean;
3
MANAGER_EXTEND: boolean;
4
L8S_SYSTEM_SCALE: boolean;
5
L8S_RESTART_TRIGGER: boolean;
6
};
7
Is this correct
Advertisement
Answer
I think the keys of your object are example.test
so based on that try this types.
JavaScript
1
14
14
1
type ApprovalTypes = {
2
'l8s.restart_trigger': boolean;
3
'l8s.system_scale': boolean;
4
'manager.cleanup': boolean;
5
'manager.extend': boolean;
6
}
7
8
const data:ApprovalTypes = {
9
'l8s.restart_trigger': true,
10
'l8s.system_scale': true,
11
'manager.cleanup': true,
12
'manager.extend': true
13
}
14