I have a code snippet that defines a person object and a function to get its values:
const person = {
name: "abc",
age: 123,
isHere: true
};
const getPersonValues = () => {
return [person.name, person.age, person.isHere];
};
const [name] = getPersonValues(); // type for "name" is string | number | boolean
In the above code, the type for name
is shown as string | number | boolean
, but I want it to be strictly a string. Is there a way to achieve this without explicitly declaring the exact type inside getPersonValues
?