Skip to content

Commit

Permalink
fix(nuxt3): export composable types (nuxt#2828)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jan 21, 2022
1 parent 9660cd8 commit cd42f62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/nuxt3/src/app/composables/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { defineNuxtComponent } from './component'
export { useAsyncData, useLazyAsyncData } from './asyncData'
export { AsyncDataOptions, AsyncData, useAsyncData, useLazyAsyncData } from './asyncData'
export { useHydration } from './hydrate'
export { useState } from './state'
export { useFetch, useLazyFetch } from './fetch'
export { useCookie } from './cookie'
export { FetchResult, UseFetchOptions, useFetch, useLazyFetch } from './fetch'
export { CookieOptions, CookieRef, useCookie } from './cookie'
export { useRequestHeaders } from './ssr'
11 changes: 10 additions & 1 deletion packages/nuxt3/test/auto-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,23 @@ describe('auto-imports:transform', () => {

const excludedNuxtHelpers = ['useHydration']

const typeExports = [
'AsyncDataOptions',
'AsyncData',
'FetchResult',
'UseFetchOptions',
'CookieOptions',
'CookieRef'
]

describe('auto-imports:nuxt3', () => {
try {
const { __dirname } = createCommonJS(import.meta.url)
const entrypointContents = readFileSync(join(__dirname, '../src/app/composables/index.ts'), 'utf8')

const names = findExports(entrypointContents).flatMap(i => i.names || i.name)
for (const name of names) {
if (excludedNuxtHelpers.includes(name)) {
if (excludedNuxtHelpers.includes(name) || typeExports.includes(name)) {
continue
}
it(`should register ${name} globally`, () => {
Expand Down

0 comments on commit cd42f62

Please sign in to comment.