untitled :
How should I defined TS type for [key, val]
pair returned from Object.entries
?
type objType = {
one: string | null;
two: string | null;
};
const obj: objType = {
one: 'one',
two: 'two',
};
Object.entries(obj).map(([key, val]) => {
console.log(key, val);
});
EDIT: this was just a simplified example. The problem was in my code
Everything works as expected. Thanks everyone!
alexako :
Do you mean define the types of the key/value pair of the .map
parameters like this?
Object.entries(obj).map(([key, val]: [Type1, Type2]) => {
console.log(key, val);
});
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=405186&siteId=1