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

Fix request typings #731

Merged
merged 2 commits into from
Mar 26, 2021
Merged

Fix request typings #731

merged 2 commits into from
Mar 26, 2021

Conversation

owenpearson
Copy link
Member

Resolves #728.

Also adds a generic type parameter for Rest.request to declare the response type for convenience.

@@ -651,8 +651,7 @@ declare namespace Types {
isLast: () => boolean;
}

class HttpPaginatedResponse extends PaginatedResult<any> {
items: string[];
class HttpPaginatedResponse<T = any> extends PaginatedResult<T> {
statusCode: number;
Copy link
Member

Choose a reason for hiding this comment

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

You accidentally deleted the items line instead of changing it to items: T[];..?

Copy link
Member Author

@owenpearson owenpearson Mar 26, 2021

Choose a reason for hiding this comment

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

PaginatedResult actually has its own items property which is already typed as T[] so deleting this line has the same effect but without duplication

Copy link
Member

Choose a reason for hiding this comment

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

ah 👍

@QuintinWillison QuintinWillison removed their request for review March 26, 2021 12:09
@QuintinWillison
Copy link
Contributor

I've not got enough TypeScript knowledge to make an informed approval on this pull request, so I think just ensure that @SimonWoolf is happy. Thanks!

@owenpearson owenpearson merged commit b8840f1 into main Mar 26, 2021
@owenpearson owenpearson deleted the feature/fix-request-typings branch March 26, 2021 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

REST client: Type Error in Types.HttpPaginatedResponse.items
3 participants