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

Typescript error on appending data values on FormData #1044

Open
vitorcamachoo opened this issue Jun 18, 2024 · 5 comments
Open

Typescript error on appending data values on FormData #1044

vitorcamachoo opened this issue Jun 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@vitorcamachoo
Copy link

vitorcamachoo commented Jun 18, 2024

What version of kubb is running?

"@kubb/cli": "^2.19.6",    
"@kubb/core": "^2.19.6",

What platform is your computer?

MacOS

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

"@kubb/plugin-oas": "2.19.6",     
"@kubb/swagger": "2.19.6",     
"@kubb/swagger-client": "2.19.6",     
"@kubb/swagger-tanstack-query": "2.19.6",     
"@kubb/swagger-ts": "2.19.6",

What steps can reproduce the bug?

When generating the client for an endpoint that supports form data, when appending the values to the FormData, it throws the following Typescript error:
Screenshot 2024-06-18 at 16 20 17

Kub configuration:

       pluginTanstackQuery({
            client: { importPath: '../../axios/custom-instance.ts' },
            output: { path: './react-query' },
            framework: 'react',
            infinite: {},
            suspense: {},
            mutate: {
                methods: ['post', 'put', 'patch', 'delete'],
                variablesType: 'mutate'
            }
        }),

How often does this bug happen?

Every time

What is the expected behavior?

It should not throw Typescript errors.

Swagger/OpenAPI file?

  ".../{project_id}/shift_reports/{shift_report_id}/import":
    post:
      summary: Imports data from an XLSX file to a draft shift report
      tags:
      - Shift report imports
      security:
      - bearerAuth: []
      parameters:
      - name: project_id
        in: path
        schema:
          type: string
          format: uuid
        required: true
      - name: shift_report_id
        in: path
        schema:
          type: string
          format: uuid
        required: true
      responses:
        '200':
          description: Shift report updated
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ShiftReport"
        '400':
          description: Bad request
        '403':
          description: Not authorised
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Error"
        '404':
          description: Not found
        '422':
          description: Update failed
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Error"
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/AuthenticationError"
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                sections:
                  type: array
                  items:
                    type: string
                    enum:
                    - contract_forces
                    - down_times
                  description: The shift report sections to import
                xlsx:
                  type: string
                  format: binary
                  description: The XLSX file

Additional information

No response

@vitorcamachoo vitorcamachoo added the bug Something isn't working label Jun 18, 2024
@stijnvanhulle
Copy link
Collaborator

What is the type of data?

@vitorcamachoo
Copy link
Author

I am getting FormData as type.
Screenshot 2024-06-19 at 15 52 49

@stijnvanhulle
Copy link
Collaborator

This feels like a Typescript config issue, see https://dev.to/deciduously/formdata-in-typescript-24cl.
Adding the following to your tsconfig.json could help in getting it to understand FormData

"lib": [
  "dom",
  "dom.iterable",
  "esnext"
],

@gentrith44belt
Copy link

gentrith44belt commented Jun 25, 2024

+1

image

@amorinabelt
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants