I am looking for a way to determine the type of a value before using it. For example, I have values "y" and "N" that I want to convert to boolean when the field is boolean.
Instead of hardcoding the field, I am looping through the object to set the value. Is there a method to inspect the type before setting it?
Below is an illustration of an object:
export class test {
id: string;
foo: number;
bar: boolean;
}
I attempted the following code, but it returns undefined until the value is set, potentially leading to overwriting what the object should be (e.g. turning into a string):
typeof test['bar']