Skip to content

Instantly share code, notes, and snippets.

@mgibson91
Created September 21, 2018 10:26
Show Gist options
  • Save mgibson91/a5e1006e006527eae284d91b74dd0852 to your computer and use it in GitHub Desktop.
Save mgibson91/a5e1006e006527eae284d91b74dd0852 to your computer and use it in GitHub Desktop.
Illustrates how to define a generic object which can contain multiple value types
interface PrimitivesObject {
[key: string]: string | number;
}
function printPrimitives(data: PrimitivesObject) {
Object.entries(data).forEach(entry => console.log(`Key: ${entry[0]}, Value: ${entry[1]}`));
}
printPrimitives({
a: 1,
b: 'string',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment