Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing type definitions in index.d.ts #278

Conversation

ohcibi
Copy link
Contributor

@ohcibi ohcibi commented Oct 25, 2019

This adds some of the missing type definitions in index.d.ts. I tried creating the declaration
using tsc but apparently another rollup-typescript plugin is necessary for this to work and I wasn't
able to generate a useful declarations file with it, so I added it manually. Fixes #277

index.d.ts Outdated
public handledRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;
public undhandledRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;
public passtroughRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;
public erroredRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public erroredRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;
public erroredRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData, error: Error): void;

index.d.ts Outdated
public erroredRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;

public prepareBody(body: string): void;
public prepareHeaders(headers: object): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public prepareHeaders(headers: object): void;
public prepareHeaders(headers: {[k: string]: string}): {[k: string]: string};

index.d.ts Outdated
public passtroughRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;
public erroredRequest(verb: string, path: string, request: FakeXMLHttpRequest & ExtraRequestData): void;

public prepareBody(body: string): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public prepareBody(body: string): void;
public prepareBody(body: string): string;

index.d.ts Outdated
@@ -32,6 +42,7 @@ export type ResponseData = [number, { [k: string]: string }, string];
interface ExtraRequestData {
params: Params;
queryParams: QueryParams;
requestBody: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https:/pretenderjs/pretender/blob/v3.0.2/src/index.ts#L396
Pretender only adds params and queryParams. I think this needs to be fixed in fake-xml-http-request package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xg-wang
Copy link
Member

xg-wang commented Oct 28, 2019

Thanks! I think this PR covers all the remaining public APIs mentioned in the readme.

@ohcibi ohcibi force-pushed the add-missing-members-in-ts-types-definitions branch 2 times, most recently from b055351 to 6033278 Compare October 28, 2019 08:53
@ohcibi ohcibi requested a review from xg-wang October 28, 2019 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incomplete types in index.d.ts
2 participants