next-safe
next-safe copied to clipboard
[BUG]: Types not correct
Describe the bug
In order to have typings from next.config, i use @ts-check
at the top of the file.
I use next-safe
in the following manner:
const nextSafe = require('next-safe');
const secureHeaders = nextSafe({
isDev: process.env.NODE_ENV !== 'production',
contentSecurityPolicy: false, // Will be dynamically set in the app
});
and get the following type error on the nextSafe call (but works in runtime since its the suggested way of usage):
(alias) module "next-safe"
import nextSafe
This expression is not callable.
Type 'typeof import("next-safe")' has no call signatures.
The types suggest that this is possible:
const { nextSafe } = require('next-safe');
but this fails in runtime/build attempt.
Also, in order to have a dynamic CSP (depending on environment + current page), i use this package in _app.tsx
and have the same problem.
Steps To Reproduce
- Create new Next.js app
- Add
@ts-check
in next.config.js or use csp in a.tsx
component - Setup
next-safe
in a recommended way - Start app
- See error
Version
v3.x.x
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct