My error is:
Error: src/app.ts(11,13): error TS2349: This expression is not callable.
Type 'typeof import("express")' has no call signatures.
My tsconfig.json
is:
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es6",
"esModuleInterop": true
},
"include": [
"./src/**/*"
]
}
My src/app.ts
has:
// const Logger = require('./lib/logger')
import express from 'express';
import bodyParser from 'body-parser';
// const finale = require('finale-rest')
// const morgan = require('morgan')
const DB = require('./models')()
// const resources = require('./resources')
const app = express()
The line in question is const app = express()
What am I doing wrong?
Make sure you don't have "esModuleInterop": true
set in tsconfig.json. Disabling this setting resolved the issue for me.
To make this work with "esModuleInterop": true
set to true in your tsconfig.json you can also do this.
import * as express from 'express';
...
const app = express.default();
source
Add @types/express
and then:
import * as express from "express";
...
const app = express();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With