How to import linq.ts into module
See original GitHub issueI 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:
- Created 7 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
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.
@NickAb Your welcome! 😄