I need help returning an array of prop: value
pairs for a custom object using the myObject[stringProp]
syntax. However, I keep encountering this error message:
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{} | EmployeeListDataRow'.
No index signature with a parameter of type 'string' was found on type '{} | EmployeeListDataRow'.
<h1>
{Object.keys(currentEmployee).map((prop) => {
return `${prop}: ${currentEmployee[prop]}\n`;
})}
</h1>
The structure of the currentEmployee
interface is as follows:
export interface EmployeeListDataRow extends Object {
id: number;
name: string;
startDate: Date;
status: string;
manager: string;
title: string;
account: string;
team: string;
rate: number;
totalComp: number;
gm: number;
ebit: number;
billable: string;
phone: string;
skills: string;
}