typescript-collections | A generically typed set of collections for use | Functional Programming library
kandi X-RAY | typescript-collections Summary
kandi X-RAY | typescript-collections Summary
A generically typed set of collections for use with TypeScript
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of typescript-collections
typescript-collections Key Features
typescript-collections Examples and Code Snippets
Community Discussions
Trending Discussions on typescript-collections
QUESTION
I'm just getting started with typescript
, and off-the-bat I've found that there aren't that many built-in data structures (doubly linked list, ordered dictionaries, queues, binary trees...).
I have found monorepos like mnemonist and typescript-collections containing tested data structures. The first has more of a following, and the second is owned by the author of typescript deep dive, a highly recommended read.
However, both are yet to gain traction and show long-term maintenance.
Moreover, typescript's roadmap does not seem to incorporate these DSs in the visible future.
Are there any currently recommended best practices pertaining to the use and maintenance of non-trivial data structures in typescript?
(I'm getting the gist of where this is going, but I feel there's benefit in asking here)
...ANSWER
Answered 2020-Aug-19 at 05:50TypeScript is just JavaScript on steroids. The only things is does is
- Allows you to use types to make your code more predictable and find errors
- Transforms some modern JS features like
?.
and??=
operators into old JavaScript that any browser can understand, basically the same thing babel does
TypeScript doesn't provide any objects that don't exist in JavaScript. Map
exists in JS - Map
exists in TS, Set
exists in JS - Set
exists in TS, but there is no objects that TS has but JS doesn't. And it will probably never contain anything like that, because adding new functionality is not the goal of this project, it's goal is to add types to reduce errors when writing code. All TypeScript type annotations get deleted after compilation, because browsers can't understand them.
Well, to be fair, TypeScript can in fact add some code to your project, namely, regenerator runtime that lets you use things, such as async
functions, for...of
loops and more, but this is just to make modern JS features work in browsers that don't understand them, this is not to provide any kind of new functionality.
If you want a data structure, that doesn't exist in JS, such as LinkedList
or Queue
, you either have to write them and type definitions for them yourself or install a package, like mnemonist
you mentioned. It's perfectly fine to do the latter and you can go with it. mnemonist
even provides type definitions (.d.ts
files), so you don't have to worry about them. If a package doesn't have type definitions included out of the box (like express
) you will usually install type definitions from DefinitelyTyped (like @types/express
). If type definitions haven't been written for the package you want, you will have to do it yourself. But this is not a problem in your case, you can just install mnemonist
and go with it.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install typescript-collections
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page