I am trying to figure this out for hours but i can not solve this seemingly easy problem.
I want to write an nodejs app with typescript.
I want to use the import statement like import express from 'express'; because then I get autocomplete in visual studio code. With require this does not work.
How can i export a function? What standard should i use? es6, commonjs,...?
How should i configure my tsconfig.json?
//tsconfig.json
{
"exclude": ["node_modules"],
"compilerOptions": {
"target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "ES6" /* Specify what module code is generated. */,
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
"outDir": "dist" /* Specify an output folder for all emitted files. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}