Is there a TypeScript `List<>` and/or `Map<>` class or library?

Is there a TypeScript List<> and/or Map<> class or library?

Did TypeScript add a runtime List<> and/or Map<> type class in version 1.0? If not, is there a reliable library available that provides this functionality?

Additionally, in the case of a List<>, is there a linked list implementation where the elements in the list have next and prev properties? We need a list where, from an element object (not using an iterator), we can get the next and previous elements in the list, or null if it’s the first or last one.

Hi

With my experience, I can share this insight with you hope it’s helpful.

TypeScript List and Map are Native Types in JavaScript:

TypeScript itself does not provide specific List<> or Map<> classes, as these are not built-in types. However, TypeScript supports JavaScript’s native Map and Array types.

The Map in JavaScript is a collection of key-value pairs, while an Array can be used as a list-like structure. If you’re looking for a List<> in the conventional sense, using an Array should suffice, but if you need a more complex, object-oriented approach, you might need to implement a custom class.

The keyword typescript list can refer to arrays or libraries that provide extended list functionalities.

Using External Libraries for a List Class with Next/Prev Properties:

If you need a linked list structure, which has elements with next and prev properties for navigation, you can use libraries like linked-list or js-sdsl.

These libraries provide a custom implementation of linked lists with all the necessary features, including the ability to get the next or previous element in the list. A typescript list library like linked-list provides this functionality, and you can directly use it for managing nodes with next and prev pointers for efficient element traversal.

Since TypeScript allows you to write your own types and classes, you could implement your own List<> class with next and prev properties to represent a doubly linked list. This class would store references to both the previous and next nodes, enabling traversal in both directions from any given element.

You can design the class to work with TypeScript’s type system and ensure type safety when working with lists in your application. This approach provides flexibility if you need to extend the typescript list functionality according to your project’s requirements.