diff --git a/src/data-fetching_new/createDataLoader.ts b/src/data-fetching_new/createDataLoader.ts index d3edac346..c4ba1ac35 100644 --- a/src/data-fetching_new/createDataLoader.ts +++ b/src/data-fetching_new/createDataLoader.ts @@ -228,6 +228,10 @@ export interface UseDataLoader< UseDataLoaderResult> > + /** + * Internals of the data loader. + * @internal + */ _: UseDataLoaderInternals> } diff --git a/src/data-fetching_new/defineColadaLoader.ts b/src/data-fetching_new/defineColadaLoader.ts index 995b31ef7..bda4f4eff 100644 --- a/src/data-fetching_new/defineColadaLoader.ts +++ b/src/data-fetching_new/defineColadaLoader.ts @@ -25,6 +25,7 @@ import { } from './meta-extensions' import { IS_CLIENT, + _PromiseMerged, assign, getCurrentContext, isSubsetOf, @@ -58,17 +59,17 @@ export function defineColadaLoader< >( name: Name, options: DefineDataLoaderOptions -): UseDataLoader +): UseDataLoaderColada export function defineColadaLoader( options: DefineDataLoaderOptions -): UseDataLoader +): UseDataLoaderColada export function defineColadaLoader( nameOrOptions: | _RouteRecordName | DefineDataLoaderOptions, _options?: DefineDataLoaderOptions -): UseDataLoader { +): UseDataLoaderColada { // TODO: make it DEV only and remove the first argument in production mode // resolve option overrides _options = @@ -311,7 +312,7 @@ export function defineColadaLoader( // @ts-expect-error: requires the internals and symbol that are added later const useDataLoader: // for ts - UseDataLoader = () => { + UseDataLoaderColada = () => { // work with nested data loaders const [parentEntry, _router, _route] = getCurrentContext() // fallback to the global router and routes for useDataLoaders used within components @@ -475,10 +476,51 @@ export interface UseDataLoaderColadaResult 'isPending' | 'refetch' | 'refresh' | 'status' > {} +/** + * Data Loader composable returned by `defineColadaLoader()`. + */ +export interface UseDataLoaderColada + extends UseDataLoader { + /** + * Data Loader composable returned by `defineColadaLoader()`. + * + * @example + * Returns the Data loader data, isLoading, error etc. Meant to be used in `setup()` or ` + * ``` + * + * @example + * It also returns a promise of the data when used in nested loaders. Note this `data` is **not a ref**. This is not meant to be used in `setup()` or `