fix(http): move destructuring inside {Request,Response}Options ctor
Previously the RequestOptions/ResponseOptions classes had constructors with a destructured argument hash (represented by the {Request,Response}OptionsArgs type). This type consists entirely of optional members. This produces a .d.ts file which includes the constructor declaration: constructor({param, otherParam}?: OptionsArgs); However, this declaration doesn't type-check properly. TypeScript determines the actual type of the hash parameter to be OptionsArgs | undefined, which it then concludes does not have a `param` or `otherParam` member. This is a bug in TypeScript ( https://github.com/microsoft/typescript/issues/10078 ). As a workaround, destructuring is moved inside the method, where it does not produce broken artifacts in the .d.ts. Fixes #16663.
This commit is contained in:
4
tools/public_api_guard/http/http.d.ts
vendored
4
tools/public_api_guard/http/http.d.ts
vendored
@ -144,7 +144,7 @@ export declare class RequestOptions {
|
||||
/** @deprecated */ search: URLSearchParams;
|
||||
url: string | null;
|
||||
withCredentials: boolean | null;
|
||||
constructor({method, headers, body, url, search, params, withCredentials, responseType}?: RequestOptionsArgs);
|
||||
constructor(opts?: RequestOptionsArgs);
|
||||
merge(options?: RequestOptionsArgs): RequestOptions;
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ export declare class ResponseOptions {
|
||||
headers: Headers | null;
|
||||
status: number | null;
|
||||
url: string | null;
|
||||
constructor({body, status, headers, statusText, type, url}?: ResponseOptionsArgs);
|
||||
constructor(opts?: ResponseOptionsArgs);
|
||||
merge(options?: ResponseOptionsArgs): ResponseOptions;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user