I don\'t understand why this code generates TypeScript error.
(It\'s not the original code and is a bit derived, so please ignore the non-sense in the example):
The correct fix is to add the property in the type definition as explained by @Nitzan Tomer.
But also you can just define property as any, if you want to write code almost as in JavaScript: