Skip to content

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

Closed

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.

Activity

  1. Scalahansolo commented on Feb 26, 2026

    @Scalahansolo

    I ran into this yesterday as well. Was going to open a PR in this repo today and hope it gets merged. It's a one line change.

    Here is the patch I have applied locally for now to move my repos forward.

    diff --git a/slugify.d.ts b/slugify.d.ts
    index 1234567..abcdefg 100644
    --- a/slugify.d.ts
    +++ b/slugify.d.ts
    @@ -1,4 +1,4 @@
    -declare module slugify {
    +declare namespace slugify {
       type ExtendArgs = {
         [key: string]: any;
       }
    
  2. Trott commented on Feb 26, 2026

    @Trott
    Collaborator

    If anyone knows if the slug module has the same problem or not, I'd appreciate a heads up. (I help maintain slugify here and there, but I'm the sole maintainer of slug.) I was unable to reproduce the issue on slugify with the minimal reproduction provided by OP here, but I assume that's because I was missing something simple about the setup that is implied and was going to get around to figuring that out yesterday, and then the day got away from me.

  3. fringe4life commented on Feb 26, 2026

    @fringe4life
    Author

    Hi, sorry if this issue is incomplete it's my first issue outside of my own account. Here is a link to my repo: firstroad. If that helps? Running bun type at the root - it's a Monorepo - triggers the typescript issue in the utils package where slugify is installed. This issue only happens for fairly recent versions of tsgo as it didn't use to occur before a recent update.

  4. fringe4life commented on Feb 26, 2026

    @fringe4life
    Author

    As for the slug package I am not sure. You would need to install a recent version of tsgo or maybe typescript 6 beta to test it out.

  5. fringe4life commented on Feb 27, 2026

    @fringe4life
    Author
  6. fringe4life commented on Feb 27, 2026

    @fringe4life
    Author

    I ran into this yesterday as well. Was going to open a PR in this repo today and hope it gets merged. It's a one line change.

    Here is the patch I have applied locally for now to move my repos forward.

    diff --git a/slugify.d.ts b/slugify.d.ts
    index 1234567..abcdefg 100644
    --- a/slugify.d.ts
    +++ b/slugify.d.ts
    @@ -1,4 +1,4 @@
    -declare module slugify {
    +declare namespace slugify {
       type ExtendArgs = {
         [key: string]: any;
       }
    

    Works for me as well

  7. fringe4life commented on Feb 27, 2026

    @fringe4life
    Author

    If anyone knows if the slug module has the same problem or not, I'd appreciate a heads up. (I help maintain slugify here and there, but I'm the sole maintainer of slug.) I was unable to reproduce the issue on slugify with the minimal reproduction provided by OP here, but I assume that's because I was missing something simple about the setup that is implied and was going to get around to figuring that out yesterday, and then the day got away from me.

    I have looked at the @types/slug and it uses namespace instead of module so I think it's likely your package is okay

  8. added a commit that references this issue on Feb 27, 2026
  9. Trott commented on Feb 27, 2026

    @Trott
    Collaborator

    I have looked at the @types/slug and it uses namespace instead of module so I think it's likely your package is okay

    slug is a more-or-less drop in replacement for slugify so switching to slug is an option too (although it does look like the fix for slugify is a one-liner and should likely see a quick merge-and-release).

  10. obedparla commented on Mar 2, 2026

    @obedparla

    Experienced the same error today when upgrading ts

  11. kongvut commented on Mar 3, 2026

    @kongvut
    Contributor

    I've submitted a PR to fix this by replacing the deprecated module keyword with namespace. You can check it out here: #206

    Thanks for maintaining this library!

  12. Trott commented on Mar 13, 2026

    @Trott
    Collaborator

    Fixed in slugify 1.6.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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