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
Describe the bug
In order to have typings from next.config, i use
@ts-checkat the top of the file.I use
next-safein the following manner:and get the following type error on the nextSafe call (but works in runtime since its the suggested way of usage):
The types suggest that this is possible:
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.tsxand have the same problem.Steps To Reproduce
@ts-checkin next.config.js or use csp in a.tsxcomponentnext-safein a recommended wayVersion
v3.x.x
Relevant log output
No response
Code of Conduct