Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use collections in Angular? #240

Open
audetto opened this issue May 29, 2020 · 4 comments
Open

How to use collections in Angular? #240

audetto opened this issue May 29, 2020 · 4 comments

Comments

@audetto
Copy link

audetto commented May 29, 2020

Probably doing something wrong here

npm install collections
npm install @types/collections

then I tried to import in various ways

import * as collections from 'collections/sorted-set';
or
import * as collections from 'collections';

but the best I get is a runtime error

ReferenceError: global is not defined

at

generic-collection.js:8

How do I do it?

@leandro-manifesto
Copy link

The latest @types/collections (5.0.2) is basically empty, so I needed to roll my own declaration files to be able to use the package in a TypeScript.

Would be nice if the package itself provided type declarations.

@icfantv
Copy link

icfantv commented Aug 22, 2020

I mean, not to be blunt, but this is how OSS works. See a need, fill a need. Does it take time? Yep. Can it be a PITA? Yep. Is everyone so lucky as to be in a position at work where they are allowed/able to contribute to OSS? Nope. But if everyone contributed a line or two, it'd be done quite quickly.

@JesusTheHun
Copy link

While I agree with you @icfantv , contribution comes from adoption. Lack of TS support means lower adoption. Also while I would love to contribute by creating the types, you must admit that creating the declaration files requires a solid knowledge of this lib.

@nicoxxl
Copy link

nicoxxl commented Oct 9, 2022

I am using vue3/vite, without @types/collections and I have the same error.

It seems to be coming from this line :

var DOMTokenList = global.DOMTokenList || function(){};

And as stated by MDN, global only exist for node.
If I understood it correctly, this fix should be simply using globalThis instead of global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants