Issue
I have interface and object which represents this interface:
MyInterface {
variableOne: string;
variableTwo: boolean;
variableThree: boolean;
...
}
Also I have function toggleFunction(x) which gets a key and toggles it in my object. Which type do I need to set in param x in my toggle function to use it for toggle all boolean key in my object?
For example I need something like: toggleFunction(x: TYPE?)
Solution
Use keyof.
function toggleFunction(x: keyof MyInterface): void {
// ...
}
Answered By - kaya3
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.