question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to import linq.ts into module

See original GitHub issue

I have my angular 1.5 typescript app organised in several files: app.ts, controller.ts, ientity.ts etc. All files re wrapped in module MyApp {}. In tsconfig I have outFile option set so that everything compiles into a single app.js file.

How do I use linq.ts in such project? If I try to import {List} from "linqts" at the top of any of my *.ts files outside module MyApp then compilation breaks because of compiler not being able to find types defined in same module but another file (for example interfaces declared in ientity.ts are no longer valid in controller.ts).

But if I put import declaration inside module MyApp {} then I get following compiler error: TS1147 Import declarations in a namespace cannot reference a module.

What is correct why to use this library in multi-file single module project setup? Am not sure if it might affect, but I use typings to reference angular, underscore, etc.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Kurtz1993commented, May 22, 2016

Now that I tried to reproduce this error I get it. I think this issue can be part of how the TypeScript compiler was created. I’ve used to work with projects that used only namespaces, no import declarations.

I think that the best approach to follow here is not using namespaces and use CommonJS or AMD modules instead. If you use CommonJS modules, you can use Webpack as your compilation process to output to a single file Here’s a webpack.config.js sample for TS.

0reactions
kutyelcommented, Jun 6, 2016

@NickAb Your welcome! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

linq javascript library with typescript es6 import syntax
I tried the normal import {Enumerable} from "linq" however it refused to find "linq" . I changed the descriptor to have declare module...
Read more >
TypeScript - Modules - TutorialsTeacher
We exported a variable and a class in the Employee.ts . However, we can only import the export module which we are going...
Read more >
Documentation - Modules - TypeScript
Import the entire module into a single variable, and use it to access the module exports. ts. import * as validator from "./ZipCodeValidator";....
Read more >
npm:linq-tsglobal | Skypack
NET Linq methods directly to javascript's Array prototype on import. It does so by making use of Typescript's global modifying module pattern.
Read more >
linq-to-typescript - npm
Import Module. import { initializeLinq } from "linq-to-typescript". // 1. Declare that the JS types implement the IEnumerable interface.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found