Skip to content

Instantly share code, notes, and snippets.

@onosendi
Last active January 5, 2022 22:18
Show Gist options
  • Save onosendi/daac1419fb56eb58ab8e1e555972cf40 to your computer and use it in GitHub Desktop.
Save onosendi/daac1419fb56eb58ab8e1e555972cf40 to your computer and use it in GitHub Desktop.
const foo = [
{ key: 'one' },
{ key: 'two' },
];
const bar = {
one: 'one',
two: 'two',
};
foo.forEach((item) => {
// Element implicitly has an 'any' type because expression of type
// 'string' can't be used to index type '{ one: string; two: string; }'.
// No index signature with a parameter of type 'string' was found one
// type '{ one: string; two: string }'
console.log(bar[item.key]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment