Hi, thanks team slugify – i'm using it in a Next.js 16 monorepo with the new TypeScript “native” compiler, and am running into a hard TS error from the bundled .d.ts.
Error
With slugify@1.6.6 and the native TypeScript compiler (via @typescript/native-preview), I consistently get:
ts
../../node_modules/.bun/slugify@1.6.6/node_modules/slugify/slugify.d.ts:1:16 - error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.
1 declare module slugify
This happens even with skipLibCheck: true – it appears to be treated as a syntax / deprecation error in the newer compiler rather than a regular lib type error.
Minimal reproduction
Dependencies (simplified):
{
"dependencies": {
"slugify": "^1.6.6"
},
"devDependencies": {
"@typescript/native-preview": "^7.0.0-dev.20260225.1"
}
}
tsconfig.json (Next.js 16-style):
{
"compilerOptions": {
"target": "es2022",
"lib": ["dom", "dom.iterable", "esnext"],
"types": ["node", "bun"],
"alwaysStrict": true,
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx"
},
"include": [
"next-env.d.ts",
"/.ts",
"/.tsx"
],
"exclude": ["node_modules"]
}
Code:
import slugify from "slugify";
const s = slugify("Example title");
Command (from the Next.js app package):
tsgo --noEmit --skipLibCheck --project tsconfig.json
tsgo internally uses @typescript/native-preview / the TS 6+ compiler
This fails with TS1540 pointing at slugify.d.ts line 1.
Context
- TypeScript 6+ (and the “native” compiler used by Next 16 / tsgo) has tightened rules around
module vs namespace for declaration files.
- The declaration in
slugify.d.ts still uses declare module slugify { ... }, which now triggers TS1540.
skipLibCheck doesn’t avoid it, since this is treated as an invalid declaration form rather than a type‑checking issue.
There are a couple of related existing issues:
Those cover callability/interop; this one is specifically about the declare module slugify syntax becoming a hard error under the newer compiler.
What would help
- Updating the declaration file to use the modern form (e.g.
declare namespace or an ES module style) so it doesn’t trigger TS1540 under TS 6+ / @typescript/native-preview.
- Alternatively, a patch/minor release with updated
.d.ts that’s compatible with Next.js 16’s default TypeScript toolchain.
In the meantime I can work around this by shadowing the types or patching slugify.d.ts locally, but having an official fix in the package would make life a lot easier for projects on the new TS compiler.
Hi, thanks team slugify – i'm using it in a Next.js 16 monorepo with the new TypeScript “native” compiler, and am running into a hard TS error from the bundled
.d.ts.Error
With
slugify@1.6.6and the native TypeScript compiler (via@typescript/native-preview), I consistently get:ts
../../node_modules/.bun/slugify@1.6.6/node_modules/slugify/slugify.d.ts:1:16 - error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.
1 declare module slugify
This happens even with
skipLibCheck: true– it appears to be treated as a syntax / deprecation error in the newer compiler rather than a regular lib type error.Minimal reproduction
Dependencies (simplified):
{ "dependencies": { "slugify": "^1.6.6" }, "devDependencies": { "@typescript/native-preview": "^7.0.0-dev.20260225.1" } }tsconfig.json (Next.js 16-style):
{ "compilerOptions": { "target": "es2022", "lib": ["dom", "dom.iterable", "esnext"], "types": ["node", "bun"], "alwaysStrict": true, "allowJs": true, "skipLibCheck": true, "strict": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "react-jsx" }, "include": [ "next-env.d.ts", "/.ts", "/.tsx" ], "exclude": ["node_modules"] }Code:
Command (from the Next.js app package):
This fails with TS1540 pointing at
slugify.d.tsline 1.Context
modulevsnamespacefor declaration files.slugify.d.tsstill usesdeclare module slugify { ... }, which now triggers TS1540.skipLibCheckdoesn’t avoid it, since this is treated as an invalid declaration form rather than a type‑checking issue.There are a couple of related existing issues:
slugifyfrom TypeScript #196 “"not a function" error when importing slugify from TypeScript”Those cover callability/interop; this one is specifically about the
declare module slugifysyntax becoming a hard error under the newer compiler.What would help
declare namespaceor an ES module style) so it doesn’t trigger TS1540 under TS 6+ /@typescript/native-preview..d.tsthat’s compatible with Next.js 16’s default TypeScript toolchain.In the meantime I can work around this by shadowing the types or patching
slugify.d.tslocally, but having an official fix in the package would make life a lot easier for projects on the new TS compiler.