Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Sep 25, 2023
1 parent f4bc910 commit 207f4b8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { importSync } from '@embroider/macros';

import { LOG_PAYLOADS } from '@ember-data/debugging';
import { DEBUG, TESTING } from '@ember-data/env';
import type { Handler, NextFn } from '@ember-data/request/-private/types';
import type { Future, Handler, NextFn, StructuredDataDocument } from '@ember-data/request';
import type Store from '@ember-data/store';
import type { StoreRequestContext, StoreRequestInfo } from '@ember-data/store/-private/cache-handler';
import type { Collection } from '@ember-data/store/-private/record-arrays/identifier-array';
Expand Down Expand Up @@ -49,10 +49,10 @@ const PotentialLegacyOperations = new Set([
]);

export const LegacyNetworkHandler: Handler = {
request<T>(context: StoreRequestContext, next: NextFn<T>): Promise<T> {
request<T>(context: StoreRequestContext, next: NextFn<T>): Future<T> | Promise<StructuredDataDocument<T>> {
// if we are not a legacy request, move on
if (context.request.url || !context.request.op || !PotentialLegacyOperations.has(context.request.op)) {
return next(context.request) as unknown as Promise<T>;
return next(context.request);
}

const { store } = context.request;
Expand Down Expand Up @@ -80,7 +80,7 @@ export const LegacyNetworkHandler: Handler = {
case 'deleteRecord':
return saveRecord(context);
default:
return next(context.request) as unknown as Promise<T>;
return next(context.request);
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/request/src/-private/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export interface Handler {
* @param context
* @param next
*/
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<StructuredDataDocument<T>> | Future<T>;
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T>;
}

export interface RequestResponse<T> {
Expand Down
3 changes: 2 additions & 1 deletion packages/store/src/-private/cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ImmutableRequestInfo,
NextFn,
RequestContext,
StructuredDataDocument,
StructuredErrorDocument,
} from '@ember-data/request/-private/types';
import type Store from '@ember-data/store';
Expand Down Expand Up @@ -309,7 +310,7 @@ export const SkipCache = Symbol.for('ember-data:skip-cache');
export const EnableHydration = Symbol.for('ember-data:enable-hydration');

export const CacheHandler: Handler = {
request<T>(context: StoreRequestContext, next: NextFn<T>): Promise<T> | Future<T> {
request<T>(context: StoreRequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T> {
// if we have no cache or no cache-key skip cache handling
if (!context.request.store || context.request.cacheOptions?.[SkipCache]) {
return next(context.request);
Expand Down
4 changes: 2 additions & 2 deletions tests/builders/tests/integration/create-record-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module('Integration - createRecord', function (hooks) {
// intercept Handler APIs to ensure they are called as expected
let response: unknown;
const TestHandler: Handler = {
request<T>(context: RequestContext): Promise<T> | Future<T> {
request<T>(context: RequestContext): Promise<T | StructuredDataDocument<T>> | Future<T> {
assert.step(`handle ${context.request.op} request`);
assert.ok(response, 'response is set');

Expand Down Expand Up @@ -165,7 +165,7 @@ module('Integration - createRecord', function (hooks) {
// intercept Handler APIs to ensure they are called as expected
let response: unknown;
const TestHandler: Handler = {
request<T>(context: RequestContext): Promise<T> | Future<T> {
request<T>(context: RequestContext): Promise<T | StructuredDataDocument<T>> | Future<T> {
assert.step(`handle ${context.request.op} request`);
assert.ok(response, 'response is set');

Expand Down
4 changes: 2 additions & 2 deletions tests/builders/tests/integration/delete-record-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module('Integration - deleteRecord', function (hooks) {
// intercept Handler APIs to ensure they are called as expected
let response: unknown;
const TestHandler: Handler = {
request<T>(context: RequestContext): Promise<T> | Future<T> {
request<T>(context: RequestContext): Promise<T | StructuredDataDocument<T>> | Future<T> {
assert.step(`handle ${context.request.op} request`);
assert.ok(response, 'response is set');

Expand Down Expand Up @@ -181,7 +181,7 @@ module('Integration - deleteRecord', function (hooks) {
// intercept Handler APIs to ensure they are called as expected
let response: unknown;
const TestHandler: Handler = {
request<T>(context: RequestContext): Promise<T> | Future<T> {
request<T>(context: RequestContext): Promise<T | StructuredDataDocument<T>> | Future<T> {
assert.step(`handle ${context.request.op} request`);
assert.ok(response, 'response is set');

Expand Down
4 changes: 2 additions & 2 deletions tests/builders/tests/integration/update-record-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module('Integration - updateRecord', function (hooks) {
// intercept Handler APIs to ensure they are called as expected
let response: unknown;
const TestHandler: Handler = {
request<T>(context: RequestContext): Promise<T> | Future<T> {
request<T>(context: RequestContext): Promise<T | StructuredDataDocument<T>> | Future<T> {
assert.step(`handle ${context.request.op} request`);
assert.ok(response, 'response is set');

Expand Down Expand Up @@ -166,7 +166,7 @@ module('Integration - updateRecord', function (hooks) {
// intercept Handler APIs to ensure they are called as expected
let response: unknown;
const TestHandler: Handler = {
request<T>(context: RequestContext): Promise<T> | Future<T> {
request<T>(context: RequestContext): Promise<T | StructuredDataDocument<T>> | Future<T> {
assert.step(`handle ${context.request.op} request`);
assert.ok(response, 'response is set');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module('RequestManager | Graceful Errors', function () {
return Promise.resolve('hello' as T);
},
};
// @ts-expect-error
manager.use([handler]);
await manager.request({ url: '/wat' });

Expand Down

0 comments on commit 207f4b8

Please sign in to comment.