Created
September 21, 2018 10:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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