I am Software Developer, currently interested in static type languages (TypeScript, Elm, ReScript) mostly in the frontend land, but working actively in Python also. I am available for mentoring.
1.Index type
Its a type accessor by index. So for example User['id'] take a type of property id from User type.
More about index type 2.Index signature type
Its a way to define the type, but limited to index type being string or number. More about that - index signatures
// Indexed type syntax only available for keys being string or numbertypeDonk={[keya:string]:string;// no more rows available}constdonk={'any_str':'any_str'};// string to string object
3.Mapped types
Mapped type is a construction allows create a type by mapping through keys being another type. This is exactly the construct which allows on creating object types with specified keys and values types.
Mapped type example:
typeKeys='a'|'b'|'c'typeDonky={[KinKeys]:string}constdonky:Donky={a:'a',b:'b',c:'c'};// a | b | c to string object
We have here three separated things.
1.Index type
Its a type accessor by index. So for example
User['id']
take a type of propertyid
fromUser
type.More about index type
2.Index signature type
Its a way to define the type, but limited to index type being
string
ornumber
. More about that - index signatures3.Mapped types
Mapped type is a construction allows create a type by mapping through keys being another type. This is exactly the construct which allows on creating object types with specified keys and values types.
Mapped type example:
More about mapped type