Typescript property does not exist on type {}

Another way is to do interface, so compiler will know that property exists.

interface IFirst{
  first:number;
}


let object = {} as IFirst;
Object.defineProperty(object, 'first', {
  value: 37,
  writable: false,
  enumerable: true,
  configurable: true
});
console.log('first property: ' + object.first);

Take a look at this question How to customize properties in TypeScript

Leave a Comment