Created
November 16, 2020 05:31
-
-
Save ariesmcrae/a82bef4ac59371432fd94ddd28e28c52 to your computer and use it in GitHub Desktop.
Typescript object with key/value pairs that are not known up front
This file contains hidden or 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 ConfigDto extends Record<string, unknown> {} | |
const myConfigDto: ConfigDto = { | |
baseUrl: "http://test.com", | |
refershRateInSeconds: 2, | |
otherStuff: {a: "a", b: "b"}, | |
showSpinner: true, | |
} | |
console.log(JSON.stringify(myConfigDto, null, 2)) | |
//output | |
<!-- | |
{ | |
"baseUrl":"http://test.com", | |
"refershRateInSeconds":2, | |
"otherStuff":{ | |
"a":"a", | |
"b":"b" | |
}, | |
"showSpinner":true | |
} | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment