Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api_guard/dist/types/ajax/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export declare class AjaxResponse<T> {
readonly responseType: XMLHttpRequestResponseType;
readonly status: number;
readonly total: number;
readonly type: string;
readonly type: AjaxResponseType;
readonly xhr: XMLHttpRequest;
constructor(
originalEvent: ProgressEvent,
xhr: XMLHttpRequest,
request: AjaxRequest,
type?: string);
type?: AjaxResponseType);
}

export interface AjaxTimeoutError extends AjaxError {
Expand Down
4 changes: 2 additions & 2 deletions src/internal/ajax/AjaxResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AjaxRequest } from './types';
import { AjaxRequest, AjaxResponseType } from './types';
import { getXHRResponse } from './getXHRResponse';

/**
Expand Down Expand Up @@ -90,7 +90,7 @@ export class AjaxResponse<T> {
* `download_load` is the type of event when download has finished and the
* response is available.
*/
public readonly type: string = 'download_load'
public readonly type: AjaxResponseType = 'download_load'
) {
const { status, responseType } = xhr;
this.status = status ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/ajax/ajax.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { map } from '../operators/map';
import { Observable } from '../Observable';
import { AjaxConfig, AjaxRequest, AjaxDirection } from './types';
import { AjaxConfig, AjaxRequest, AjaxDirection, ProgressEventType } from './types';
import { AjaxResponse } from './AjaxResponse';
import { AjaxTimeoutError, AjaxError } from './errors';

Expand Down Expand Up @@ -414,7 +414,7 @@ export function fromAjax<T>(config: AjaxConfig): Observable<AjaxResponse<T>> {
* @param event the actual event object.
*/
const createResponse = (direction: AjaxDirection, event: ProgressEvent) =>
new AjaxResponse<T>(event, xhr, _request, `${direction}_${event.type}`);
new AjaxResponse<T>(event, xhr, _request, `${direction}_${event.type as ProgressEventType}` as const);

/**
* Wires up an event handler that emits a Response object to the consumer, used for
Expand Down
4 changes: 4 additions & 0 deletions src/internal/ajax/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { PartialObserver } from '../types';
*/
export type AjaxDirection = 'upload' | 'download';

export type ProgressEventType = 'loadstart' | 'progress' | 'load';

export type AjaxResponseType = `${AjaxDirection}_${ProgressEventType}`;

/**
* The object containing values RxJS used to make the HTTP request.
*
Expand Down