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

[BUG] [Typescript] Generic type 'URLParse<Query>' requires 1 type argument(s). #12625

Open
2 of 6 tasks
charlax opened this issue Jun 17, 2022 · 2 comments
Open
2 of 6 tasks

Comments

@charlax
Copy link

charlax commented Jun 17, 2022

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Contrary to v5.4.0, the generate http/http.ts does not include the @ts-ignore comment and as such fail type checking:

./node_modules/.../http/http.ts:44:18
Type error: Generic type 'URLParse<Query>' requires 1 type argument(s).

  42 |     private headers: { [key: string]: string } = {};
  43 |     private body: RequestBody = undefined;
> 44 |     private url: URLParse;
     |                  ^
  45 |
  46 |     /**
  47 |      * Creates the request context using a http method and request resource url
info  - Checking validity of types .%

(tested with url-parse types 1.4.8. I get other errors with 1.4.4)

openapi-generator version

v6.0.0

OpenAPI declaration file content or url

N/A

Generation Details

N/A

Steps to reproduce
Related issues/PRs

Introduced in #11465

Suggest a fix

Add back the // @ts-ignore?

@carusooo
Copy link

Manually adding the //@ts-ignore didn't solve the issue for me.

I ended up changing the type of the URLParse in the RequestContext to URLParse<Record<string, string | undefined>>; so that it looks like this

/**
 * Represents an HTTP request context
 */
export class RequestContext {
    private headers: { [key: string]: string } = {};
    private body: RequestBody = undefined;
    private url: URLParse<Record<string, string | undefined>>;

@thenbe
Copy link

thenbe commented Sep 9, 2022

Fixed this by using the pinned version of @types/url-parse as defined in the generated package.json. At time of writing, this is "@types/url-parse": "1.4.4".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants