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

'node_modules/linq-es2015/dist/linq.d.ts' is not a module. #9

Closed
WouterBos opened this issue Jul 3, 2016 · 5 comments
Closed

'node_modules/linq-es2015/dist/linq.d.ts' is not a module. #9

WouterBos opened this issue Jul 3, 2016 · 5 comments

Comments

@WouterBos
Copy link

WouterBos commented Jul 3, 2016

When importing, I get the message "Error TS2306 File 'D:/XXX/node_modules/linq-es2015/dist/linq.d.ts' is not a module." I use the import like this: "import {asEnumerable, Range} from 'linq-es2015";"
Furthermore I have a list of messages like "Cannot find name 'iterable'".

I also tried to load the sources with "import {asEnumerable, Range} from "linq-es2015/src/linq.ts";". But then I get a "JsErrorScriptException (0x30001)" without being related to some specific file.

Error found in Visual Studio 2015

@ENikS
Copy link
Owner

ENikS commented Jul 4, 2016

You have to build with TSC 1.18.xx and set target to es2015. For sample look at configuration file

@WouterBos
Copy link
Author

Ah! Thanks. I'm afraid that in that case this project is not a good fit for me because I also use other libraries that require a more recent TSC.

@WouterBos
Copy link
Author

I assume the same limitation exists for linq-es5. What is the limitation of this library to upgrade to a higher TSC? Is it a practical or a technical one?

@WouterBos
Copy link
Author

I thought of a simpler solution: I only load the definition file like /// <reference path="../node_modules/linq-es5/dist/linq.d.ts" />, assuming that the definition file is less dependent on a specific version of TypeScript. But I don't know how to use it. I don't know how to get the correct type. An example would help me a lot.

My best effort so far:


let fruits = ["apple", "mango", "orange", "passionfruit", "grape"] as Enumerable<string>; // Neither type is assignable to the other.
let result: string = fruits.FirstOrDefault();
alert(result);```

@ENikS
Copy link
Owner

ENikS commented Jul 10, 2016

You don't need to add reference to the linq-xx.d.ts file. TSC v1.8 compiler will pick its location from the package.json file.
For sample on how to use the library please follow this link: https://tonicdev.com/eniks/using-linq
... or you could locate link on the npmjs package page saying: Try it out: "Test linq-es2015 in your browser." and it will let you execute it in node.

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

2 participants