question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Types] Make `queryParams` strongly-typed

See original GitHub issue

Right now, there are no types for queryParams; the default value is {}, so any object will match this type.

Some autocomplete will be nice, so I propose such alternative:

type GetListQueryParams = {
  page?: number
  perPage?: number
  sort?: string
  filter?: string
  expand?: string
}

// BaseCrudService@41
protected _getList<T = M>(basePath: string, page = 1, perPage = 30, queryParams: GetListQueryParams = {}): Promise<ListResult<T>> {
// ...
}

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
seweracommented, Dec 7, 2022

@ganigeorgiev, please find PR #102 ready for review.

1reaction
ganigeorgievcommented, Dec 6, 2022

Hm, this was requested previously as part of https://github.com/pocketbase/js-sdk/issues/64.

For now let’s keep the scope of the issue minimal and not merge the BaseCrudService and CrudService since this will require some major updates to the tests too.

We can add type for the query params but the declaration(s) needs to be a little more “relaxed” for better backward comparability and to allow setting also custom query props, eg. something like:

export interface BaseQueryParams {
    [key: string]: any;

    expand?:      string;
    $autoCancel?: boolean;
    $cancelKey?:  string;
}

export interface ListQueryParams extends BaseQueryParams {
    page?:    number;
    perPage?: number;
    sort?:    string;
    filter?:  string;
}

@sewera If you don’t have the time to work on this, I’ll implement it sometime at the end of the week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# 9 records as strongly-typed ids - Part 2: ASP.NET Core ...
C# 9 records as strongly-typed ids - Part 2: ASP.NET Core route and query parameters · Model binding of route and query string...
Read more >
angular - How can i make my query parameters to be type safe?
Angular HTTP client expects query parameters with string types only because you can only send string in a URL in the end.
Read more >
Strongly-typed way to manage URL parameters. Works with ...
Strongly -typed way to manage URL parameters. Works with react-router. Allows to strong-type parameters in routes and search.
Read more >
Strongly Typing Dapper Queries Using nameof - Scott Sauber
Use nameof in order to strongly type your Dapper queries, so renaming a property on your C# doesn't break your Dapper query or...
Read more >
strongly typed http - leontrolski
First we have our index, this has no params and no query parameters - simple. Next we have the route /v1/:foo , this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found