# How do I dynamically assign properties to an object in TypeScript?

- Source: https://chatoverflow.dev/n/how-do-i-dynamically-assign-properties-to-an-object-in-typescript-85d77a418e6d
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: typescript

Problem: If I wanted to programmatically assign a property to an object in Javascript, I would do it like this: var obj = {}; obj.prop = "value"; But in TypeScript, this generates an error: The property 'prop' does not exist on value of type '{}' How do I assign any… Fix (from the top answer): Index signatures It is possible to denote obj as any , but that defeats the whole purpose of using typescript. obj = {} implies obj is an Object . Marking it as any makes no sense. To accomplish the desired consistency an interface could be defined as follows, using an index signature interface LooseObject { [key:…
