This expression is not callable. error on typescript helmet 5.0.1
See original GitHub issueThe full error is:
src/server/index.ts:6:9 - error TS2349: This expression is not callable.
Type 'typeof import("C:/try/t21/helet-issue/node_modules/helmet/dist/index")' has no call signatures.
6 app.use(helmet({ contentSecurityPolicy: false }));
~~~~~~
Previously in version 4.6.0 it works great, but in the latest helmet 5.0.1 version it does not work. /src/server/index.ts
import * as express from 'express';
import * as helmet from 'helmet';
const app = express();
app.use(helmet({ contentSecurityPolicy: false })); // this line shows the error.
app.listen(3002, () => console.log("Server started"));
Here’s my tsconfig:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/server",
"module": "commonjs",
"baseUrl": "./",
"moduleResolution": "node",
"target": "es2017",
"lib": [
"es2020",
"dom"
]
},
}
You can see this in code sandbox: https://codesandbox.io/s/s4fuq
When I change the import to:
import helmet from 'helmet';
I get a runtime error: TypeError: (0 , helmet_1.default) is not a function
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Typescript error This expression is not callable. #2404 - GitHub
Bug Report I am getting the following error even when using fastify examples from the documentation. src/dist-server.ts:3:16 - error TS2349: ...
Read more >How to use helmet.js from typescript? - Stack Overflow
I upgraded my helmet version from v 3.23.3 and now I get a compile error "This expression is not callable." for the "helmet()"....
Read more >helmet - npm
Helmet helps you secure your Express apps by setting various HTTP headers. It's not a silver bullet, but it can help!
Read more >This expression is not callable. error on typescript helmet 5.0.1
The full error is: src/server/index.ts:6:9 - error TS2349: This expression is not callable.
Read more >Compare Versions | @brainhubeu/gatsby-docs-kit | npm
We found errors while resolving dependencies that may result in an incomplete or inaccurate dependency graph. Show details. Errors found while resolving some ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@EvanHahn I was also seeing this issue in my project and like @GuyMev I would like to avoid modifying my
tsconfig.json
just for this library.But the good news, I might have a possible fix to solve everyone’s problems here. I’m not the biggest ESM/CJS/TS expert, but will open a pull request for review and see what you think.
Setting esModuleInterop to true on tsconfig.json worked for me: