diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index 99e840de30..3091af2522 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -57,6 +57,13 @@ async function initNuxt (nuxt: Nuxt) { // Add module augmentations directly to NuxtConfig opts.references.push({ path: resolve(nuxt.options.buildDir, 'types/schema.d.ts') }) opts.references.push({ path: resolve(nuxt.options.buildDir, 'types/app.config.d.ts') }) + + for (const layer of nuxt.options._layers) { + const declaration = join(layer.cwd, 'index.d.ts') + if (fse.existsSync(declaration)) { + opts.references.push({ path: declaration }) + } + } }) // Add import protection diff --git a/test/fixtures/basic/extends/bar/index.d.ts b/test/fixtures/basic/extends/bar/index.d.ts new file mode 100644 index 0000000000..3d1121c544 --- /dev/null +++ b/test/fixtures/basic/extends/bar/index.d.ts @@ -0,0 +1,5 @@ +declare module 'bing' { + interface BingInterface { + foo: 'bar' + } +} diff --git a/test/fixtures/basic/types.ts b/test/fixtures/basic/types.ts index 07dab0835e..035a71abc8 100644 --- a/test/fixtures/basic/types.ts +++ b/test/fixtures/basic/types.ts @@ -182,3 +182,9 @@ describe('app config', () => { expectTypeOf().toMatchTypeOf() }) }) + +describe('extends type declarations', () => { + it('correctly adds references to tsconfig', () => { + expectTypeOf().toEqualTypeOf<{ foo: 'bar' }>() + }) +})