You can not. These are fully dynamic properties added at runtime, so you may not know that they are at compile time. I also claim that you do not want to know that they are at an early stage; if you have enforcement restrictions, you should simply declare them yourself (first example below).
If your code depends on a set of accessories, you should place them directly in the interface or contract, because you know in advance that you expect them and should advertise it. You can use additional properties (with a child access element) to make this easier:
interface HasSomeProps { foo: string; bar?: string; } class DoesTheProps implements HasSomeProps { set foo(value) {
If you have a group of sequential (or semi-consistent) accessories, you can define an indexer for your type, for example:
interface AccessStrings { [key: string]: string; }
This does not allow you to restrict keys. If you want this, you must explicitly specify the properties.
source share