mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
feat(nuxt): allow exposing type augmentations from extends layers (#7442)
This commit is contained in:
parent
5893dc201f
commit
13dc0b94c4
@ -57,6 +57,13 @@ async function initNuxt (nuxt: Nuxt) {
|
|||||||
// Add module augmentations directly to NuxtConfig
|
// 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/schema.d.ts') })
|
||||||
opts.references.push({ path: resolve(nuxt.options.buildDir, 'types/app.config.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
|
// Add import protection
|
||||||
|
5
test/fixtures/basic/extends/bar/index.d.ts
vendored
Normal file
5
test/fixtures/basic/extends/bar/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'bing' {
|
||||||
|
interface BingInterface {
|
||||||
|
foo: 'bar'
|
||||||
|
}
|
||||||
|
}
|
6
test/fixtures/basic/types.ts
vendored
6
test/fixtures/basic/types.ts
vendored
@ -182,3 +182,9 @@ describe('app config', () => {
|
|||||||
expectTypeOf<AppConfig>().toMatchTypeOf<ExpectedMergedAppConfig>()
|
expectTypeOf<AppConfig>().toMatchTypeOf<ExpectedMergedAppConfig>()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('extends type declarations', () => {
|
||||||
|
it('correctly adds references to tsconfig', () => {
|
||||||
|
expectTypeOf<import('bing').BingInterface>().toEqualTypeOf<{ foo: 'bar' }>()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user