A computed property name derives an object's key from a runtime value. Keep its allowed names narrow if downstream readers expect a fixed set.
Worked example
interface Job {
id: number;
name: string;
done: boolean;
}
const job: Job = { id: 1, name: "Build", done: false };
console.log({ ...job, done: job.name.length > 0 } satisfies Job);Result
{ id: 1, name: 'Build', done: true }Implementation notes
A computed key can collide with an existing property during a spread. Choose the precedence order in the object literal deliberately.
Try it yourself
Compare inference for a literal key and a variable typed as string.
Open the TypeScript example →Editorial date October 8, 2026 · Published December 6, 2026