Index signature giúp khai báo kiểu của tên thuộc tính và giá trị của nó trong vật thể, dù không biết vật thể đó có cấu trúc thế nào

The syntax of an index signature is simple and looks similar to the syntax of a property. But with one difference: write the type of the key inside the square brackets: { [key: KeyType]: ValueType }.

Nguồn:: Index Signatures in TypeScript

Index signature và record là các cách khai báo kiểu vật thể


Cập nhật lần cuối : 30 tháng 6, 2024
Tạo : 3 tháng 11, 2023