Could someone please explain exactly how exports and imports work in NodeJS using Typescript?
My setup is:
- NodeJS
- Everything in Typescript
- TSLint
- Typings
I am messing about with exports/imports instead of doing some proper coding, its driving me nuts, and cannot find any proper explanation of how it works.
Import
Can you please explain following:
var module = require ("module");
import module = require("module");
import module from "module";
import {something} from "module";
import * as module from "module";
Export
Can you please explain following
export = something;
export default something;
export interface|class something;
Questions
- How do properly export/import a class without initiating it
- How do properly export/import a class with it being initiated (construct did run)
- How do I properly export/import a class and interface
- How do I properly export/import class and multiple interfaces
- When to use modules declarations, what are they good for and why is tslint throwing errors at me if I try to use them.
I cannot seem to find proper way of doing exports vs. imports so my IDE is not covered in red and throwing hundreds of errors at me.
General Questions
- Is there even a way to not get errors using nodejs/typescript/tslint?
- TSLint is screaming at me for almost anything I type... it is extremely frustrating since there is 0 explanation to most of the errors. Is it even worth using it?
List of questions goes on and on, but im sure once some of the above is answered, I can pick up on the rest.
Thank you and sorry for such a general question, but my frustration level just reached the top...
namespaces in Typescript should be avoided as much as possible - Bruno Grieder