Skip to content

Commit b01dce4

Browse files
committed
fix: upgrade support for pinia colada 0.13.0
1 parent e61d071 commit b01dce4

File tree

5 files changed

+48
-37
lines changed

5 files changed

+48
-37
lines changed

examples/nuxt/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"preview": "nuxt preview"
88
},
99
"devDependencies": {
10-
"@pinia/nuxt": "^0.7.0",
10+
"@pinia/nuxt": "^0.8.0",
1111
"nuxt": "^3.14.1592",
1212
"unplugin-vue-router": "workspace:*"
1313
},
1414
"dependencies": {
15-
"@pinia/colada": "^0.12.1",
15+
"@pinia/colada": "^0.13.0",
1616
"pinia": "^2.2.8"
1717
}
1818
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
}
191191
},
192192
"devDependencies": {
193-
"@pinia/colada": "^0.12.1",
193+
"@pinia/colada": "^0.13.0",
194194
"@shikijs/vitepress-twoslash": "1.23.1",
195195
"@tanstack/vue-query": "^5.60.6",
196196
"@types/node": "^22.10.1",
@@ -209,7 +209,7 @@
209209
"nodemon": "^3.1.7",
210210
"p-series": "^3.0.0",
211211
"pinia": "^2.2.8",
212-
"prettier": "^3.3.3",
212+
"prettier": "^3.4.1",
213213
"rimraf": "^6.0.1",
214214
"rollup": "^4.27.4",
215215
"semver": "^7.6.3",

pnpm-lock.yaml

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/data-loaders/createDataLoader.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import { ErrorDefault } from './types-config'
99
/**
1010
* Base type for a data loader entry. Each Data Loader has its own entry in the `loaderEntries` (accessible via `[LOADER_ENTRIES_KEY]`) map.
1111
*/
12-
export interface DataLoaderEntryBase<Data = unknown, TError = unknown> {
12+
export interface DataLoaderEntryBase<
13+
TData = unknown,
14+
TError = unknown,
15+
// TODO: technically we could just make loaders pass TData | undefined as the first type parameter
16+
// this requires quite some code updates, this version is retro-compatible
17+
TDataInitial extends TData | undefined = TData | undefined,
18+
> {
1319
/**
1420
* Data stored in the entry.
1521
*/
16-
data: ShallowRef<Data | undefined>
22+
data: ShallowRef<TData | TDataInitial>
1723

1824
/**
1925
* Error if there was an error.
@@ -51,7 +57,7 @@ export interface DataLoaderEntryBase<Data = unknown, TError = unknown> {
5157
* Data that was staged by a loader. This is used to avoid showing the old data while the new data is loading. Calling
5258
* the internal `commit()` function will replace the data with the staged data.
5359
*/
54-
staged: Data | typeof STAGED_NO_VALUE
60+
staged: TData | typeof STAGED_NO_VALUE
5561

5662
/**
5763
* Error that was staged by a loader. This is used to avoid showing the old error while the new data is loading.
@@ -272,11 +278,11 @@ export interface UseDataLoaderInternals<Data = unknown, TError = unknown> {
272278
/**
273279
* Return value of a loader composable defined with `defineLoader()`.
274280
*/
275-
export interface UseDataLoaderResult<Data = unknown, TError = ErrorDefault> {
281+
export interface UseDataLoaderResult<TData = unknown, TError = ErrorDefault> {
276282
/**
277283
* Data returned by the loader. If the data loader is lazy, it will be undefined until the first load.
278284
*/
279-
data: ShallowRef<Data>
285+
data: ShallowRef<TData>
280286

281287
/**
282288
* Whether there is an ongoing request.

src/data-loaders/defineColadaLoader.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,21 +562,24 @@ export type DefineDataColadaLoaderOptions<
562562
*/
563563
export interface DataColadaLoaderContext extends DataLoaderContextBase {}
564564

565-
export interface UseDataLoaderColadaResult<Data>
566-
extends UseDataLoaderResult<Data, ErrorDefault>,
565+
export interface UseDataLoaderColadaResult<
566+
TData,
567+
TError = ErrorDefault,
568+
TDataInitial extends TData | undefined = TData | undefined,
569+
> extends UseDataLoaderResult<TData | TDataInitial, ErrorDefault>,
567570
Pick<
568-
UseQueryReturn<Data, any>,
571+
UseQueryReturn<TData, TError, TDataInitial>,
569572
'isPending' | 'status' | 'asyncStatus' | 'state'
570573
> {
571574
refetch: (
572575
to?: RouteLocationNormalizedLoaded
573576
// TODO: we might need to add this in the future
574577
// ...coladaArgs: Parameters<UseQueryReturn<Data, any>['refresh']>
575-
) => ReturnType<UseQueryReturn<Data, any>['refetch']>
578+
) => ReturnType<UseQueryReturn<TData, TError, TDataInitial>['refetch']>
576579

577580
refresh: (
578581
to?: RouteLocationNormalizedLoaded
579-
) => ReturnType<UseQueryReturn<Data, any>['refetch']>
582+
) => ReturnType<UseQueryReturn<TData, TError, TDataInitial>['refetch']>
580583
}
581584

582585
/**
@@ -649,8 +652,11 @@ export interface UseDataLoaderColada_DefinedData<Data>
649652
>
650653
}
651654

652-
export interface DataLoaderColadaEntry<Data, TError = unknown>
653-
extends DataLoaderEntryBase<Data, TError> {
655+
export interface DataLoaderColadaEntry<
656+
TData,
657+
TError = unknown,
658+
TDataInitial extends TData | undefined = TData | undefined,
659+
> extends DataLoaderEntryBase<TData, TError, TDataInitial> {
654660
/**
655661
* Reactive route passed to pinia colada so it automatically refetch
656662
*/
@@ -664,7 +670,7 @@ export interface DataLoaderColadaEntry<Data, TError = unknown>
664670
/**
665671
* Extended options for pinia colada
666672
*/
667-
ext: UseQueryReturn<Data, TError> | null
673+
ext: UseQueryReturn<TData, TError, TDataInitial> | null
668674
}
669675

670676
interface TrackedRoute {

0 commit comments

Comments
 (0)