New to TypeScript. I read the book Pro Angular, I can not understand the record:

ngOnChanges(changes: {[property: string]: SimpleChange }) {...} 

In particular, the function accepts a change argument, the type of which is an anonymous object. Inside this object sits an anonymous array with a property element of type string. What is SimpleChange? Or am I messed up?

    1 answer 1

    No, this is not an anonymous array, it is a way of typing values ​​of unknown keys of an object ( part of the index types specification ). Record

     { name: string, [key: <type A>]: <type B> } 

    says that in this object there will definitely be a property name with type string, and all other keys with type <type A> will contain values ​​with type <type B> . The key name (key and property) does not bear any load and can be arbitrary.

    Specifically, in your example, an object is passed in which there is an arbitrary number of string keys, each of which corresponds to a SimpleChange value.