Skip to content

Instantly share code, notes, and snippets.

@bacher
Created November 26, 2024 13:32
Show Gist options
  • Save bacher/1e48b096b06fed382a92550b67da6a92 to your computer and use it in GitHub Desktop.
Save bacher/1e48b096b06fed382a92550b67da6a92 to your computer and use it in GitHub Desktop.
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