Coder Social home page Coder Social logo

Comments (6)

FreeAoi avatar FreeAoi commented on June 4, 2024 1

I will take a look on this and if its necessary I will make a PR to fix it

from openapi-typescript.

jaredLunde avatar jaredLunde commented on June 4, 2024 1

Oh wow, I'm so sorry. I have a repro: https://stackblitz.com/edit/vitejs-vite-3tdy1b?file=src%2FApp.tsx

If body is undefined you can reproduce the issue easily in the browser. client.POST('/', {body:undefined})

from openapi-typescript.

FreeAoi avatar FreeAoi commented on June 4, 2024

Hello! I can't reproduce the bug with the information provided, could you please create a repository where we can test it or let me know if there is another detail when doing the reproduction?

from openapi-typescript.

jaredLunde avatar jaredLunde commented on June 4, 2024

Perhaps it is related to Bun, Astro, or Vite in some way. I'm not 100% sure where the Request global is being set, but I had assumed it was the browser's. Unfortunately I can't figure out how to install Bun on StackBlitz to dig further into a repro. Regardless, there's clearly some incompatibility in the vast JS/TS ecosystem as a result of overwriting Request properties that are native to the Request object Finding some other means of adding them would probably be beneficial for that reason.

For example:

const nativeRequest = new Request()

class CustomRequest extends Request {
  constructor(input, init) {
    super(input, init);

    // add custom parameters
    for (const key in init) {
      if (!(key in nativeRequest)) {
        this[key] = init[key];
      }
    }
  }
}

Or

class CustomRequest extends Request {
  constructor(input, init) {
    super(input, init);

    // add custom parameters
    for (const key in init) {
      if (!(key in this)) {
        this[key] = init[key];
      }
    }
  }
}

from openapi-typescript.

jaredLunde avatar jaredLunde commented on June 4, 2024

Since body can be undefined, I'm guessing the naive check agains !this["body"] in the CustomRequest object is returning a false positive, while key in this would not return a false positive.

from openapi-typescript.

FreeAoi avatar FreeAoi commented on June 4, 2024

Alr makes sense https://github.com/drwpow/openapi-typescript/blob/main/packages/openapi-fetch/src/index.js#L17 return a false positive, you could do the PR fixing this by changing that conditional to !(key in this)

from openapi-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.