Skip to content

Type augmentations broken in v4 #32727

@cernymatej

Description

@cernymatej

Environment

  • Operating System: Darwin
  • Node Version: v22.17.0
  • Nuxt Version: 3.17.7
  • CLI Version: 3.26.4
  • Nitro Version: 2.12.4
  • Package Manager: pnpm@10.12.1
  • Builder: -
  • User Config: compatibilityDate, devtools, extends
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-1zim1ccd?file=project/app/plugins/example.ts,layer/types/foo.ts,project/types/index.d.ts

Describe the bug

Once I migrated my projects to v4, I noticed that all my type augmentations stopped working.

Let's assume that there is a composable, which has some options:

// layer/app/composables/useFoo.ts
export function useFoo(option: keyof FooOptions) {}

// layer/types/foo.ts
export interface FooOptions {
    'from-layer': any
}

and the options are augmented in a project extending the layer, where the composable comes from:

// project/types/index.d.ts
declare module '@layer-foo/types/foo' {
    interface FooOptions {
        'from-project': any
    }
}

export {}

In v3, both options were accepted:

Image

However, in v4, only the base interface is considered:

Image

Additional context

The v4 projects are using the new default tsconfig

{
  // https://nuxt.com/docs/guide/concepts/typescript
  "files": [],
  "references": [
    {
      "path": "./.nuxt/tsconfig.app.json"
    },
    {
      "path": "./.nuxt/tsconfig.server.json"
    },
    {
      "path": "./.nuxt/tsconfig.shared.json"
    },
    {
      "path": "./.nuxt/tsconfig.node.json"
    }
  ]
}

Logs

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions