Created
November 26, 2024 13:32
-
-
Save bacher/1e48b096b06fed382a92550b67da6a92 to your computer and use it in GitHub Desktop.
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
type Keys = 'a' | 'b'; | |
type Data = Record<Keys, string>; | |
function getSomeKey(): Keys { | |
return 'a'; | |
} | |
const data: Data = { | |
a: 'hello', | |
b: 'world', | |
}; | |
const dataUpdated = { | |
...data, | |
[getSomeKey()]: 5, | |
}; | |
console.log('results', data, dataUpdated); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment