[6.1.4] typescript 5.0.4 still unhappy with how exports look export assignment
ritschwumm opened this issue · comments
after the fix for #414 in a project with "type": "module",
and "moduleResolution": "nodenext",
i now get this error:
node_modules/helmet/index.d.ts:120:1 - error TS2309: An export assignment cannot be used in a module with other exported elements.
120 export = helmet
~~~~~~~~~~~~~~~
Found 1 error.
Sorry about this! I thought I checked this case but I guess not.
Do you have a sample project that reproduces this issue?
sadly, the project i see this in is closed source - but i can try to make some small reproducer tomorrow.
i wonder whether the "🎭 Masquerading as CJS" in https://arethetypeswrong.github.io/?p=helmet%406.1.4 is related to all this...
That may be. I've struggled to get it right for all possible project setups.
If you could give me a fuller tsconfig.json
, I might be able to help.
In the short term, you can downgrade to helmet@6.0.1
for now.
Yeah same issue here
Latest working version for us is 6.1.2
.
I have the same issue with TS 4.9.4
, my tsconfig.json
{
"compilerOptions": {
"lib": ["es2022"],
"module": "commonjs",
"target": "es2021",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"inlineSources": true,
"sourceRoot": "/",
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"strict": true,
"rootDir": ".",
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"noImplicitReturns": true,
"noUnusedParameters": true,
"typeRoots": ["./node_modules/@types", "./type-defs"],
"paths": {
"~/*": ["./*"]
}
}
}
i use 6.1.3 right now and just cast helmet to any
before calling the function. not great, but it works.
Same issue with TypeScript 5.0.4 and this tsconfig.json
:
{
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ESNext"],
"module": "CommonJS",
"moduleResolution": "Node",
"noEmitOnError": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": true,
"strictFunctionTypes": true,
"target": "ES6"
},
"exclude": ["dist", "node_modules", "spec"]
}
@EvanHahn Here's a minimal reproduction: https://github.com/haines/helmet-export-repro
The problem occurs with the default TypeScript compiler options (the only option I changed from those generated by tsc --init
was to remove skipLibCheck
).
Downgrading helmet to 6.1.2 resolves the problem.
Sorry all. In trying to make things work for some people, it seems I broke it for others. I'll prepare a fix ASAP.
In the meantime, downgrading to a previous version should work. helmet@6.0.1
and helmet@6.1.2
reportedly work for people.
@haines Thanks for the reproduction app.
This should be fixed in helmet@6.1.5
. Sorry for the trouble! Let me know if you encounter any other problems.
thank you very much, 6.1.5 works like a charm
Excellent, thank you!