Skip to content

Commit 7f2b413

Browse files
committed
chore: Remove IRequestOptions / IResponseOptions
BREAKING CHANGE: Reasons: 1) Interfaces should not start with letter ‘I’ 2) Interfaces do not help with mistype properties, but literal types do. - microsoft/TypeScript#3823 - https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#strict-object-literal-assignment-checking
1 parent 3e06a50 commit 7f2b413

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

modules/http/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export {Request} from 'http/src/static_request';
1919
export {Response} from 'http/src/static_response';
2020

2121
export {
22-
IRequestOptions,
23-
IResponseOptions,
22+
RequestOptionsArgs,
23+
ResponseOptionsArgs,
2424
Connection,
2525
ConnectionBackend
2626
} from 'http/src/interfaces';

modules/http/src/base_request_options.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {CONST_EXPR, CONST, isPresent, isString} from 'angular2/src/facade/lang';
22
import {Headers} from './headers';
33
import {RequestModesOpts, RequestMethods, RequestCacheOpts, RequestCredentialsOpts} from './enums';
4-
import {IRequestOptions} from './interfaces';
4+
import {RequestOptionsArgs} from './interfaces';
55
import {Injectable} from 'angular2/di';
66
import {URLSearchParams} from './url_search_params';
77

@@ -13,7 +13,7 @@ import {URLSearchParams} from './url_search_params';
1313
*
1414
* All values are null by default.
1515
*/
16-
export class RequestOptions implements IRequestOptions {
16+
export class RequestOptions {
1717
/**
1818
* Http method with which to execute the request.
1919
*
@@ -36,7 +36,7 @@ export class RequestOptions implements IRequestOptions {
3636
url: string;
3737
search: URLSearchParams;
3838
constructor({method, headers, body, mode, credentials, cache, url, search}:
39-
IRequestOptions = {}) {
39+
RequestOptionsArgs = {}) {
4040
this.method = isPresent(method) ? method : null;
4141
this.headers = isPresent(headers) ? headers : null;
4242
this.body = isPresent(body) ? body : null;
@@ -53,7 +53,7 @@ export class RequestOptions implements IRequestOptions {
5353
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override
5454
* existing values.
5555
*/
56-
merge(options?: IRequestOptions): RequestOptions {
56+
merge(options?: RequestOptionsArgs): RequestOptions {
5757
return new RequestOptions({
5858
method: isPresent(options) && isPresent(options.method) ? options.method : this.method,
5959
headers: isPresent(options) && isPresent(options.headers) ? options.headers : this.headers,

modules/http/src/base_response_options.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Injectable} from 'angular2/di';
22
import {isPresent, isJsObject} from 'angular2/src/facade/lang';
33
import {Headers} from './headers';
44
import {ResponseTypes} from './enums';
5-
import {IResponseOptions} from './interfaces';
5+
import {ResponseOptionsArgs} from './interfaces';
66

77
/**
88
* Creates a response options object similar to the
@@ -13,15 +13,15 @@ import {IResponseOptions} from './interfaces';
1313
*
1414
* All values are null by default.
1515
*/
16-
export class ResponseOptions implements IResponseOptions {
16+
export class ResponseOptions {
1717
// TODO: ArrayBuffer | FormData | Blob
1818
body: string | Object;
1919
status: number;
2020
headers: Headers;
2121
statusText: string;
2222
type: ResponseTypes;
2323
url: string;
24-
constructor({body, status, headers, statusText, type, url}: IResponseOptions = {}) {
24+
constructor({body, status, headers, statusText, type, url}: ResponseOptionsArgs = {}) {
2525
this.body = isPresent(body) ? body : null;
2626
this.status = isPresent(status) ? status : null;
2727
this.headers = isPresent(headers) ? headers : null;
@@ -30,7 +30,7 @@ export class ResponseOptions implements IResponseOptions {
3030
this.url = isPresent(url) ? url : null;
3131
}
3232

33-
merge(options?: IResponseOptions): ResponseOptions {
33+
merge(options?: ResponseOptionsArgs): ResponseOptions {
3434
return new ResponseOptions({
3535
body: isPresent(options) && isPresent(options.body) ? options.body : this.body,
3636
status: isPresent(options) && isPresent(options.status) ? options.status : this.status,

modules/http/src/http.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {isString, isPresent, isBlank, makeTypeError} from 'angular2/src/facade/lang';
22
import {Injectable} from 'angular2/src/di/decorators';
3-
import {IRequestOptions, Connection, ConnectionBackend} from './interfaces';
3+
import {RequestOptionsArgs, Connection, ConnectionBackend} from './interfaces';
44
import {Request} from './static_request';
55
import {BaseRequestOptions, RequestOptions} from './base_request_options';
66
import {RequestMethods} from './enums';
@@ -111,7 +111,7 @@ export class Http {
111111
* object can be provided as the 2nd argument. The options object will be merged with the values
112112
* of {@link BaseRequestOptions} before performing the request.
113113
*/
114-
request(url: string | Request, options?: IRequestOptions): EventEmitter {
114+
request(url: string | Request, options?: RequestOptionsArgs): EventEmitter {
115115
var responseObservable: EventEmitter;
116116
if (isString(url)) {
117117
responseObservable = httpRequest(
@@ -126,15 +126,15 @@ export class Http {
126126
/**
127127
* Performs a request with `get` http method.
128128
*/
129-
get(url: string, options?: IRequestOptions): EventEmitter {
129+
get(url: string, options?: RequestOptionsArgs): EventEmitter {
130130
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
131131
RequestMethods.GET, url)));
132132
}
133133

134134
/**
135135
* Performs a request with `post` http method.
136136
*/
137-
post(url: string, body: string, options?: IRequestOptions): EventEmitter {
137+
post(url: string, body: string, options?: RequestOptionsArgs): EventEmitter {
138138
return httpRequest(
139139
this._backend,
140140
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
@@ -144,7 +144,7 @@ export class Http {
144144
/**
145145
* Performs a request with `put` http method.
146146
*/
147-
put(url: string, body: string, options?: IRequestOptions): EventEmitter {
147+
put(url: string, body: string, options?: RequestOptionsArgs): EventEmitter {
148148
return httpRequest(
149149
this._backend,
150150
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
@@ -154,15 +154,15 @@ export class Http {
154154
/**
155155
* Performs a request with `delete` http method.
156156
*/
157-
delete (url: string, options?: IRequestOptions): EventEmitter {
157+
delete (url: string, options?: RequestOptionsArgs): EventEmitter {
158158
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
159159
RequestMethods.DELETE, url)));
160160
}
161161

162162
/**
163163
* Performs a request with `patch` http method.
164164
*/
165-
patch(url: string, body: string, options?: IRequestOptions): EventEmitter {
165+
patch(url: string, body: string, options?: RequestOptionsArgs): EventEmitter {
166166
return httpRequest(
167167
this._backend,
168168
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
@@ -172,7 +172,7 @@ export class Http {
172172
/**
173173
* Performs a request with `head` http method.
174174
*/
175-
head(url: string, options?: IRequestOptions): EventEmitter {
175+
head(url: string, options?: RequestOptionsArgs): EventEmitter {
176176
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
177177
RequestMethods.HEAD, url)));
178178
}
@@ -190,7 +190,7 @@ export class Jsonp extends Http {
190190
* object can be provided as the 2nd argument. The options object will be merged with the values
191191
* of {@link BaseRequestOptions} before performing the request.
192192
*/
193-
request(url: string | Request, options?: IRequestOptions): EventEmitter {
193+
request(url: string | Request, options?: RequestOptionsArgs): EventEmitter {
194194
var responseObservable: EventEmitter;
195195
if (isString(url)) {
196196
url = new Request(mergeOptions(this._defaultOptions, options, RequestMethods.GET, url));

modules/http/src/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Connection {
4242
* Interface for options to construct a Request, based on
4343
* [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
4444
*/
45-
export interface IRequestOptions {
45+
export type RequestOptionsArgs = {
4646
url?: string;
4747
method?: RequestMethods;
4848
search?: string | URLSearchParams;
@@ -58,7 +58,7 @@ export interface IRequestOptions {
5858
* Interface for options to construct a Response, based on
5959
* [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.
6060
*/
61-
export interface IResponseOptions {
61+
export type ResponseOptionsArgs = {
6262
// TODO: Support Blob, ArrayBuffer, JSON
6363
body?: string | Object | FormData;
6464
status?: number;

0 commit comments

Comments
 (0)