Skip to content

TypeScript native / TS 6+ (Next 16) – TS1540 on declare module slugify in slugify.d.ts #205

@fringe4life

Description

@fringe4life

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions