I'm attempting to write an Express server with TypeScript. Everything is written from scratch instead of a CLI, so I'm sure there's an error somewhere in my setup.
I want to write import express, { Application } from express just as I have it in other servers I've written, but I get the error:
import express from 'express'
~~~~~~~
node_modules/@types/express/index.d.ts:115:1
115 export = e;
~~~~~~~~~~~
This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
TS Config:
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"moduleResolution": "node",
"experimentalDecorators": true,
"allowJs": true,
"noEmit": true,
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true
},
"exclude": [
"node_modules"
]
}
And the package JSON:
"dependencies": {
"@types/bcrypt": "^3.0.0",
"@types/body-parser": "^1.19.0",
"@types/knex": "^0.16.1",
"@types/moment": "^2.13.0",
"bcrypt": "^4.0.1",
"body-parser": "^1.19.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"knex": "^0.20.13",
"moment": "^2.24.0",
"pg": "^8.0.0",
"tsc": "^1.20150623.0",
"typescript": "^3.8.3"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-typescript": "^7.9.0",
"@types/express": "^4.17.4"
}
Babel is currently unused. I've tried changing module as well with no luck.