Skip to content

Commit

Permalink
fix: remove id field from ctx.loader
Browse files Browse the repository at this point in the history
BREAKING CHANGE: we no longer allow `id` so it'll TS will be unhappy
  • Loading branch information
neurosnap committed Aug 2, 2023
1 parent 6f4230b commit 10451a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ test('overriding default loader behavior', (t) => {
const fetchUsers = api.create(
`/users`,
function* (ctx: ApiCtx<any, { users: User[] }>, next) {
const id = ctx.name;
yield next();

if (!ctx.json.ok) {
Expand All @@ -304,7 +303,7 @@ test('overriding default loader behavior', (t) => {
return acc;
}, {});

ctx.loader = { id, message: 'yes', meta: { wow: true } };
ctx.loader = { message: 'yes', meta: { wow: true } };
ctx.actions.push(users.actions.add(curUsers));
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface FetchJsonCtx<P = any, ApiSuccess = any, ApiError = any>
export interface ApiCtx<Payload = any, ApiSuccess = any, ApiError = any>
extends FetchJsonCtx<Payload, ApiSuccess, ApiError> {
actions: Action[];
loader: LoadingMapPayload<Record<string, any>> | null;
loader: Omit<LoadingMapPayload<Record<string, any>>, 'id'> | null;
cache: boolean;
cacheData: any;
}
Expand Down

0 comments on commit 10451a4

Please sign in to comment.